Linux文件类型-Ext2目录项Structureofadirectoryentry*#defineEXT2NAMELEN255I*Thenewversionofthedirectory entry.SinceExT2structuresarestored in intel byteorder,andthenamelenfieldcouldneverbebiggerthan255chars,it'ssafetoreclaimtheextrabyteforthe file_type field. */structext2dir_entry_2I*Inode number */_u32inode;_u16rec_len;I*Directory entry length *u8 name_len;[* Name length */u8file_type;*File name *char name[EXT2_NAME_LEN];3;I*Ext2directory file types.Only thelow3bits areused.The otherbits are reservedfor now.*enum(EXT2_FT_UNKNOWN,EXT2_FT REGFILEEXT2FTDIREXT2 FT CHRDEV,EXT2FTBLKDEV,EXT2 FT FIFO,EXT2 FT SOCKEXT2_FT_SYMLINK,EXT2_FT MAX3;7.6
7.6 Linux 文件类型-Ext2 目录项 /* Structure of a directory entry */ #define EXT2_NAME_LEN 255 /* The new version of the directory entry. Since EXT2 structures are stored in intel byte order, and the name_len field could never be bigger than 255 chars, it's safe to reclaim the extra byte for the file_type field. */ struct ext2_dir_entry_2 { _u32 inode; /* Inode number */ _u16 rec_len; /* Directory entry length */ _u8 name_len; /* Name length */ _u8 file_type; char name[EXT2_NAME_LEN]; /* File name */ }; /* Ext2 directory file types. Only the low 3 bits are used. The other bits are reserved for now.*/ enum { EXT2_FT_UNKNOWN, EXT2_FT_REG_FILE, EXT2_FT_DIR, EXT2_FT_CHRDEV, EXT2_FT_BLKDEV, EXT2_FT_FIFO, EXT2_FT_SOCK, EXT2_FT_SYMLINK, EXT2_FT_MAX };
Linux文件类型(cont.)ext2 inode :struct ext2_inode /*文件类型和访问权限*/u16 i mode:_u16i_uid;/*拥有者的用户ID*/u32i_size;/*文件大小*/*最近一次访问时间*_u32 i_atime;*创建时间*_u32 i_ctime;*最近一次修改时间*_u32 i_mtime;_u16i_gid;/*文件的组ID*/u32iblocks;/*分配给该文件的磁盘块的数目*/_u32i_block[EXT2NBLOCKS];/*指向磁盘块的指针*/;7.7
7.7 Linux 文件类型(cont.) ext2_inode: struct ext2_inode { _u16 i_mode; /* 文件类型和访问权限 */ _u16 i_uid; /* 拥有者的用户ID */ _u32 i_size; /* 文件大小 */ _u32 i_atime; /* 最近一次访问时间 */ _u32 i_ctime; /* 创建时间 */ _u32 i_mtime; /* 最近一次修改时间 */ _u16 i_gid; /* 文件的组ID */ _u32 i_blocks;/* 分配给该文件的磁盘块的数目 */ _u32 i_block[EXT2_N_BLOCKS];/*指向磁盘块的指针 */ . };
Linux文件类型(cont)设备文件:字符设备文件和块设备文件。Linux把对设备的I/Oz作为对文件的读取/写入操作内核提供了对设备处理和对文件处理的统一接口。fdo (for floppy drive 0)hda (for harddisk a)lpo(forlineprinterO)tty (forteletypeterminal)管道(FIFO)文件:用于在进程间传递数据。Linux对管道的操作与文件操作相同,它把管道做为文件进行处理。链接文件:又称符号链接文件,它提供了共享文件的一种方法。socket文件7.8
7.8 Linux 文件类型(cont.) 设备文件:字符设备文件和块设备文件。Linux把对设 备的I/Oz作为对文件的读取/写入操作内核提供了对设 备处理和对文件处理的统一接口。 fd0 (for floppy drive 0) hda (for harddisk a) lp0 ( for line printer 0) tty (for teletype terminal) 管道(FIFO)文件:用于在进程间传递数据。Linux对管 道的操作与文件操作相同,它把管道做为文件进行处 理。 链接文件:又称符号链接文件,它提供了共享文件的 一种方法。 socket文件
文件系统结构FileSystemStructurerootost+founsbinbirbootoottmryar005adminfacultystudentsliblocalbirfdhdttygroup passwdbobksarwarpersonalcoursesee231ee446passwdletterlabsexams目录文件非目录文件solutionsmidlmid2图7.2典型的LINUX文件系统结构7.9
7.9 文件系统结构File System Structure bin boot dev etc home lib lost+found mnt opt proc root sbin tmp usr var root admin faculty students bin lib local bobk sarwar courses personal ee231 ee446 fd hd tty group passwd letter passwd exams labs mid1 mid2 solutions 目录文件 非目录文件 图7.2 典型的LINUX文件系统结构