欢迎来到天天文库
浏览记录
ID:39548549
大小:56.00 KB
页数:8页
时间:2019-07-06
《FAT相关结构及操作过程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第1章数据结构1.1关键数据结构structfat_fs_struct{structpartition_struct*partition;//分区类型,扇区偏移、总长度structfat_header_structheader;//fat的相关信息,包括分区起始扇区,总长度,fat表的大小,扇区大小,簇大小,数据区的偏移,根目录区的偏移};该文件结构代表了整个fat分区Partition及header的具体的结构定义如下:structfat_header_struct{offset_tsize;//磁盘空间大小,以字节来计算offse
2、t_tfat_offset;//fat的起始位置,以字节来计算uint32_tfat_size;//fat有多大,以字节来计算uint16_tsector_size;//扇区大小,以字节来计算uint16_tcluster_size;//簇大小,以字节来计算offset_tcluster_zero_offset;//数据区域的地址,以字节来计算offset_troot_dir_offset;//根目录地址,以字节来计算#ifFAT_FAT32_SUPPORTcluster_troot_dir_cluster;#endif};//以上数
3、据是从分区第一个扇区读出来并整理的相关数据structpartition_struct{device_read_tdevice_read;device_read_interval_tdevice_read_interval;device_write_tdevice_write;device_write_interval_tdevice_write_interval;uint8_ttype;//分区类型uint32_toffset;//分区的偏移(单位为扇区)uint32_tlength;//总长度(单位为扇区,每个512字节)};以上
4、信息是从第一扇区读出来的数据第1章目录及文件的操作过程1.1打开分区操作/*openfirstpartition*/structpartition_struct*partition=partition_open(sd_raw_read,d_raw_read_interval,sd_raw_write,sd_raw_write_interval,0);//打开第0个分区,获取分区数据1.2打开文件系统/*openfilesystem*/structfat_fs_struct*fs=fat_open(partition);//获取文件系统
5、信息1.3打开根目录/*openrootdirectory*/structfat_dir_entry_structdirectory;fat_get_dir_entry_of_path(fs,"/",&directory);structfat_dir_struct*dd=fat_open_dir(fs,&directory);打开目录分为两个动作1打开根目录,获取到目录项数据fat_dir_entry_struct2根据获得目录项数据,打开相应的目录,并获得目录描述符fat_dir_struct如何找到目录项:n打开根目录,获取到根目
6、录的描述符n使用根目录的描述符,根据名称通过fat_read_dir获取fat_dir_entry_structn检查fat_dir_entry_struct中的名称是否与制定目录名称匹配n匹配则则返回相应的目录项查看目录项的数据结构:structfat_dir_entry_struct{/**Thefile'sname,truncatedto31characters.*/charlong_name[32];//文件名/**Thefile'sattributes.MaskoftheFAT_ATTRIB_*constants.*/uin
7、t8_tattributes;//目录属性,只读/**Compressedrepresentationofmodificationtime.*/uint16_tmodification_time;//修改时间/**Compressedrepresentationofmodificationdate.*/uint16_tmodification_date;//修改日期/**Theclusterinwhichthefile'sfirstbyteresides.*/cluster_tcluster;//在哪一簇/**Thefile'ssiz
8、e.*/uint32_tfile_size;//文件大小/**Thetotaldiskoffsetofthisdirectoryentry.*/offset_tentry_offset;//字节偏移};该目录项包含了名称
此文档下载收益归作者所有