170 likes | 383 Views
Chapter 7. Files and File System Structure. 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
E N D
Chapter 7 Files and File System Structure
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) • Character special • Block special • Named Pipe (FIFO)
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
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 'd1_inode' for V1 file systems and 'd2_inode' for V2 file systems. */ EXTERNstructinode { mode_ti_mode; /* file type, protection, etc. nlink_ti_nlinks; /* how many links to this file uid_ti_uid; /* user id of the file's owner gid_ti_gid; /* group number off_ti_size; /* current file size in bytes time_ti_atime; /* time of last access (V2 only) time_ti_mtime; /* when was file data last changed time_ti_ctime; /* when was inode itself changed (V2 only) zone_ti_zone[V2_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.7 Relationship between the file lab1.c in a directory and its contents on disk
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