Title: Files and File System Structure
1Chapter 7
- Files and File System Structure
2Files 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)
3LINUX File Types
- Simple/Ordinary file
- Directory
- Symbolic (soft) link
- Special File (device)
- Character special
- Block special
- Named Pipe (FIFO)
4Filenames
- 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
5Table 7.1 Commonly Used Extensions
6Figure 7.2Â A typical LINUX file system structure
7Table 7.2 Main Subdirectories in /usr
8Table 7.2 Main Subdirectories in /usr
9Table 7.3 Some Important Hidden Files and Their
Purposes
10Table 7.4 Summary of the Output of the ls -l
Command
11Figure 7.1Â Structure of a directory entry
12Figure 7.5 Â Contents of an inode
13Inode 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. / - 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 (V2
only) - time_t i_mtime / when was file data last
changed - time_t i_ctime / when was inode itself
changed (V2 only) - zone_t i_zoneV2_NR_TZONES / zone
numbers for direct, ind, and dbl ind /
14Figure 7.6 Â Logical view of a disk drive(an
array of disk blocks)
15Figure 7.7Â Relationship between the file lab1.c
in a directory and its contents on disk
16Figure 7.8Â Relationship between a file
descriptor and contents of the file on disk
17Figure 7.9Â Relationship of a file descriptor and
the corresponding file