《2022年Linux下FAT文件系统 .pdf》由会员分享,可在线阅读,更多相关《2022年Linux下FAT文件系统 .pdf(4页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#define SECTOR_SIZE 512 /* sector size (bytes) */ #define SECTOR_BITS 9 /* log2(SECTOR_SIZE) */ #define MSDOS_DPB (MSDOS_DPS) /* dir entries per block */ #define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */ #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry) #define MSDOS_DPS_BITS 4 /* log2(MS
2、DOS_DPS) */ #define CF_LE_W(v) le16_to_cpu(v) #define CF_LE_L(v) le32_to_cpu(v) #define CT_LE_W(v) cpu_to_le16(v) #define CT_LE_L(v) cpu_to_le32(v) #define MSDOS_ROOT_INO 1 /* = MINIX_ROOT_INO */ #define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry) */ /* directory limit */ #define FAT_MAX
3、_DIR_ENTRIES (65536) #define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES fat_bits = 32 ? 0 x0FFFFF00 : 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 4 页 - - - - - - - - - MSDOS_SB(s)-fat_bits = 16 ? 0 xFF00 : 0 xF00) | (x) /* start of data clusters entry (number of
4、reserved clusters) */ #define FAT_START_ENT 2 /* maximum number of clusters */ #define MAX_FAT12 0 xFF4 #define MAX_FAT16 0 xFFF4 #define MAX_FAT32 0 x0FFFFFF6 #define MAX_FAT(s) (MSDOS_SB(s)-fat_bits = 32 ? MAX_FAT32 : MSDOS_SB(s)-fat_bits = 16 ? MAX_FAT16 : MAX_FAT12) /* bad cluster mark */ #defin
5、e BAD_FAT12 0 xFF7 #define BAD_FAT16 0 xFFF7 #define BAD_FAT32 0 x0FFFFFF7 /* standard EOF */ #define EOF_FAT12 0 xFFF #define EOF_FAT16 0 xFFFF #define EOF_FAT32 0 x0FFFFFFF #define FAT_ENT_FREE (0) #define FAT_ENT_BAD (BAD_FAT32) #define FAT_ENT_EOF (EOF_FAT32) #define FAT_FSINFO_SIG1 0 x41615252
6、#define FAT_FSINFO_SIG2 0 x61417272 #define IS_FSINFO(x) (le32_to_cpu(x)-signature1) = FAT_FSINFO_SIG1 & le32_to_cpu(x)-signature2) = FAT_FSINFO_SIG2) struct _fat_dirent long d_ino; _kernel_off_t d_off; unsigned short d_reclen; char d_name256; /* We must not include limits.h! */ ; /* ioctl commands
7、*/ #define VFAT_IOCTL_READDIR_BOTH _IOR(r, 1, struct _fat_dirent2) #define VFAT_IOCTL_READDIR_SHORT _IOR(r, 2, struct _fat_dirent2) /* has used 0 x72 (r) in collision, so skip a few */ #define FAT_IOCTL_GET_ATTRIBUTES _IOR(r, 0 x10, _u32) #define FAT_IOCTL_SET_ATTRIBUTES _IOW(r, 0 x11, _u32) 名师资料总结
8、- - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 4 页 - - - - - - - - - struct fat_boot_sector _u8 ignored3; /* Boot strap short or near jump */ _u8 system_id8; /* Name - can be used to special case partition manager volumes */ _u8 sector_size2; /* bytes per logical sect
9、or */ _u8 sec_per_clus; /* sectors/cluster */ _le16 reserved; /* reserved sectors */ _u8 fats; /* number of FATs */ _u8 dir_entries2; /* root directory entries */ _u8 sectors2; /* number of sectors */ _u8 media; /* media code */ _le16 fat_length; /* sectors/FAT */ _le16 secs_track; /* sectors per tr
10、ack */ _le16 heads; /* number of heads */ _le32 hidden; /* hidden sectors (unused) */ _le32 total_sect; /* number of sectors (if sectors = 0) */ /* The following fields are only used by FAT32 */ _le32 fat32_length; /* sectors/FAT */ _le16 flags; /* bit 8: fat mirroring, low 4: active fat */ _u8 vers
11、ion2; /* major, minor filesystem version */ _le32 root_cluster; /* first cluster in root directory */ _le16 info_sector; /* filesystem info sector */ _le16 backup_boot; /* backup boot sector */ _le16 reserved26; /* Unused */ ; struct fat_boot_fsinfo _le32 signature1; /* 0 x41615252L */ _le32 reserve
12、d1120; /* Nothing as far as I can tell */ _le32 signature2; /* 0 x61417272L */ _le32 free_clusters; /* Free cluster count. -1 if unknown */ _le32 next_cluster; /* Most recently allocated cluster */ _le32 reserved24; ; struct msdos_dir_entry _u8 nameMSDOS_NAME;/* name and extension */ _u8 attr; /* at
13、tribute bits */ _u8 lcase; /* Case for base and extension */ _u8 ctime_cs; /* Creation time, centiseconds (0-199) */ _le16 ctime; /* Creation time */ _le16 cdate; /* Creation date */ _le16 adate; /* Last access date */ 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3
14、 页,共 4 页 - - - - - - - - - _le16 starthi; /* High 16 bits of cluster in FAT32 */ _le16 time,date,start;/* time, date and first cluster */ _le32 size; /* file size (in bytes) */ ; /* Up to 13 characters of the name */ struct msdos_dir_slot _u8 id; /* sequence number for slot */ _u8 name0_410; /* firs
15、t 5 characters in name */ _u8 attr; /* attribute byte */ _u8 reserved; /* always 0 */ _u8 alias_checksum; /* checksum for 8.3 alias */ _u8 name5_1012; /* 6 more characters in name */ _le16 start; /* starting cluster number, 0 in long slots */ _u8 name11_124; /* last 2 characters in name */ ; #ifdef _KERNEL_ /* media of boot sector */ static inline int fat_valid_media(u8 media) return 0 xf8 = media | media = 0 xf0; #endif /* !_KERNEL_ */ 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 4 页 - - - - - - - - -
限制150内