exfat文件系统(七)------exfat_core.c详解(一)------CLUSTER HEAP(BMAP_DENTRY_T以及相关)

来源:互联网 发布:百度软件手机助手 编辑:程序博客网 时间:2024/05/26 20:19

        根据前面章节已经大致了解了exfat文件系统流程,我个人感觉可以算入门了,但是离深入理解还远着。前面,我都是纵向学习,从本章开始横向学习exfat模块文件。

本章节重点解析exfat_core.c文件()。

在学习中要结合我前面dump出来的exfat文件系统的hex文件对以前没有理解清楚的函数继续深入研究。

        在重新看load_alloc_bitmap函数时,结合导出来的exfat文件系统的hex信息,check如下学习心得:


clu.dir = p_fs->root_dir;//0x04

clu.flags = 0x01;


for (i = 0; i < p_fs->dentries_per_clu; i++) {
ep = (BMAP_DENTRY_T *) get_entry_in_dir(sb, &clu, i, NULL);
if (!ep)
return FFS_MEDIAERR;


type = p_fs->fs_func->get_entry_type((DENTRY_T *) ep);


if (type == TYPE_UNUSED)
break;
if (type != TYPE_BITMAP)
continue;


if (ep->flags == 0x0) {
p_fs->map_clu  = GET32_A(ep->start_clu);
map_size = (UINT32) GET64_A(ep->size);


p_fs->map_sectors = ((map_size-1) >> p_bd->sector_size_bits) + 1;


p_fs->vol_amap = (struct buffer_head **) MALLOC(sizeof(struct buffer_head *) * p_fs->map_sectors);
if (p_fs->vol_amap == NULL)
return FFS_MEMORYERR;


sector = START_SECTOR(p_fs->map_clu);


for (j = 0; j < p_fs->map_sectors; j++) {
p_fs->vol_amap[j] = NULL;
ret = sector_read(sb, sector+j, &(p_fs->vol_amap[j]), 1);
if (ret != FFS_SUCCESS) {
i=0;
while (i < j)
brelse(p_fs->vol_amap[i++]);


FREE(p_fs->vol_amap);
p_fs->vol_amap = NULL;
return ret;
}
}


p_fs->pbr_bh = NULL; //wangxf14_study init for later
return FFS_SUCCESS;
}
}




UINT32 exfat_get_entry_type(DENTRY_T *p_entry)
{
FILE_DENTRY_T *ep = (FILE_DENTRY_T *) p_entry;


if (ep->type == 0x0) {
return TYPE_UNUSED;
} else if (ep->type < 0x80) {
return TYPE_DELETED;
} else if (ep->type == 0x80) {
return TYPE_INVALID;
} else if (ep->type < 0xA0) {
if (ep->type == 0x81) {
return TYPE_BITMAP;

} else if (ep->type == 0x82) {
return TYPE_UPCASE;
} else if (ep->type == 0x83) {
return TYPE_VOLUME;
} else if (ep->type == 0x85) {
if (GET16_A(ep->attr) & ATTR_SUBDIR)
return TYPE_DIR;
else
return TYPE_FILE;
}
return TYPE_CRITICAL_PRI;
} else if (ep->type < 0xC0) {
if (ep->type == 0xA0) {
return TYPE_GUID;
} else if (ep->type == 0xA1) {
return TYPE_PADDING;
} else if (ep->type == 0xA2) {
return TYPE_ACLTAB;
}
return TYPE_BENIGN_PRI;
} else if (ep->type < 0xE0) {
if (ep->type == 0xC0) {
return TYPE_STREAM;
} else if (ep->type == 0xC1) {
return TYPE_EXTEND;
} else if (ep->type == 0xC2) {
return TYPE_ACL;
}
return TYPE_CRITICAL_SEC;
}


return TYPE_BENIGN_SEC;
}


以上红色代码能够体现出如下64M.hex中的exfat文件系统数据



0 0
原创粉丝点击