Chapter 7 Files and File System Structure Files

  • Slides: 17
Download presentation
Chapter 7 Files and File System Structure

Chapter 7 Files and File System Structure

Files under LINUX • File: a sequence of bytes • All files, I/O devices,

Files under LINUX • File: a sequence of bytes • All files, I/O devices, and interfaces are treated as files • Directories are also files (Files containing list of files within them)

LINUX File Types • • Simple/Ordinary file Directory Symbolic (soft) link Special File (device)

LINUX File Types • • Simple/Ordinary file Directory Symbolic (soft) link Special File (device) – Character special – Block special • Named Pipe (FIFO)

Filenames • Linux does not attach any particular meaning to any file • Application

Filenames • Linux does not attach any particular meaning to any file • Application programs determine how to use files • Some applications require certain extensions, but LINUX does not use any standard convention for file extensions • Linux file names can be up to 255 characters (including any extension and the “. ” before it) • It is permitted but generally unwise to embed special or invisible characters in file names

Table 7. 1 Commonly Used Extensions

Table 7. 1 Commonly Used Extensions

Figure 7. 2 A typical LINUX file system structure

Figure 7. 2 A typical LINUX file system structure

Table 7. 2 Main Subdirectories in /usr

Table 7. 2 Main Subdirectories in /usr

Table 7. 2 Main Subdirectories in /usr

Table 7. 2 Main Subdirectories in /usr

Table 7. 3 Some Important Hidden Files and Their Purposes

Table 7. 3 Some Important Hidden Files and Their Purposes

Table 7. 4 Summary of the Output of the ls -l Command

Table 7. 4 Summary of the Output of the ls -l Command

Figure 7. 1 Structure of a directory entry

Figure 7. 1 Structure of a directory entry

Figure 7. 5 Contents of an inode

Figure 7. 5 Contents of an inode

Inode Structure • /* Inode table. This table holds inodes that are currently in

Inode Structure • /* Inode table. This table holds inodes that are currently in use. In some cases they have been opened by an open() or creat() system call, in other cases the file system itself needs the inode for one reason or another, such as to search a directory for a path name. The first part of the struct holds fields that are present on the disk; the second part holds fields not present on the disk. The disk inode part is also declared in "type. h" as 'd 1_inode' for V 1 file systems and 'd 2_inode' for V 2 file systems. */ EXTERN struct inode { mode_t i_mode; /* file type, protection, etc. nlink_t i_nlinks; /* how many links to this file } uid_t i_uid; /* user id of the file's owner gid_t i_gid; /* group number off_t i_size; /* current file size in bytes time_t i_atime; /* time of last access (V 2 only) time_t i_mtime; /* when was file data last changed time_t i_ctime; /* when was inode itself changed (V 2 only) zone_t i_zone[V 2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */

Figure 7. 6 Logical view of a disk drive (an array of disk blocks)

Figure 7. 6 Logical view of a disk drive (an array of disk blocks)

Figure 7. 7 Relationship between the file lab 1. c in a directory and

Figure 7. 7 Relationship between the file lab 1. c in a directory and its contents on disk

Figure 7. 8 Relationship between a file descriptor and contents of the file on

Figure 7. 8 Relationship between a file descriptor and contents of the file on disk

Figure 7. 9 Relationship of a file descriptor and the corresponding file

Figure 7. 9 Relationship of a file descriptor and the corresponding file