reactos操作系统实现(130)

前端之家收集整理的这篇文章主要介绍了reactos操作系统实现(130)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

vfatMakeRootFCB函数是用来创建FAT文件系统的根目录,实现代码如下:@H_403_7@

#001 PVFATFCB@H_403_7@

#002 vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)@H_403_7@

#003 {@H_403_7@

#004 PVFATFCB FCB;@H_403_7@

#005 ULONG FirstCluster,CurrentCluster,Size = 0;@H_403_7@

#006 NTSTATUS Status = STATUS_SUCCESS;@H_403_7@

@H_403_7@

设置根目录名称@H_403_7@

#007 UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"//");@H_403_7@

#008 @H_403_7@

@H_403_7@

根据文件名称创建一块文件控制块。@H_403_7@

#009 FCB = vfatNewFCB(pVCB,&NameU);@H_403_7@

#010 if (FCB->Flags & FCB_IS_FATX_ENTRY)@H_403_7@

#011 {@H_403_7@

@H_403_7@

如果扩展的FAT入口,就进行相应的扩展的FAT属性设置。@H_403_7@

#012 memset(FCB->entry.FatX.Filename,' ',42);@H_403_7@

@H_403_7@

设置FAT最大的文件大小。@H_403_7@

#013 FCB->entry.FatX.FileSize = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;@H_403_7@

@H_403_7@

设置当前控制块为目录属性@H_403_7@

#014 FCB->entry.FatX.Attrib = FILE_ATTRIBUTE_DIRECTORY;@H_403_7@

@H_403_7@

设置为第一簇。@H_403_7@

#015 FCB->entry.FatX.FirstCluster = 1;@H_403_7@

#016 Size = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;@H_403_7@

#017 }@H_403_7@

#018 else@H_403_7@

#019 {@H_403_7@

@H_403_7@

设置FAT属性@H_403_7@

#020 memset(FCB->entry.Fat.ShortName,11);@H_403_7@

#021 FCB->entry.Fat.FileSize = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;@H_403_7@

#022 FCB->entry.Fat.Attrib = FILE_ATTRIBUTE_DIRECTORY;@H_403_7@

@H_403_7@

设置FAT32支持的目录属性@H_403_7@

#023 if (pVCB->FatInfo.FatType == FAT32)@H_403_7@

#024 {@H_403_7@

#025 CurrentCluster = FirstCluster = pVCB->FatInfo.RootCluster;@H_403_7@

#026 FCB->entry.Fat.FirstCluster = (unsigned short)(FirstCluster & 0xffff);@H_403_7@

#027 FCB->entry.Fat.FirstClusterHigh = (unsigned short)(FirstCluster >> 16);@H_403_7@

#028 @H_403_7@

#029 while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status))@H_403_7@

#030 {@H_403_7@

#031 Size += pVCB->FatInfo.BytesPerCluster;@H_403_7@

#032 Status = NextCluster (pVCB,FirstCluster,&CurrentCluster,FALSE);@H_403_7@

#033 }@H_403_7@

#034 }@H_403_7@

#035 else@H_403_7@

#036 {@H_403_7@

@H_403_7@

设置FAT16FAT12属性@H_403_7@

#037 FCB->entry.Fat.FirstCluster = 1;@H_403_7@

#038 Size = pVCB->FatInfo.rootDirectorySectors * pVCB->FatInfo.BytesPerSector;@H_403_7@

#039 }@H_403_7@

#040 }@H_403_7@

#041 FCB->ShortHash.Hash = FCB->Hash.Hash;@H_403_7@

#042 FCB->RefCount = 2;@H_403_7@

#043 FCB->dirIndex = 0;@H_403_7@

#044 FCB->RFCB.FileSize.QuadPart = Size;@H_403_7@

#045 FCB->RFCB.ValidDataLength.QuadPart = Size;@H_403_7@

#046 FCB->RFCB.AllocationSize.QuadPart = Size;@H_403_7@

#047 FCB->RFCB.IsFastIoPossible = FastIoIsNotPossible;@H_403_7@

#048 @H_403_7@

@H_403_7@

文件控制块创建缓存。@H_403_7@

#049 vfatFCBInitializeCacheFromVolume(pVCB,FCB);@H_403_7@

@H_403_7@

文件控制块添加HASH表里,以便加速访问。@H_403_7@

#050 vfatAddFCBToTable(pVCB,FCB);@H_403_7@

#051 @H_403_7@

#052 return(FCB);@H_403_7@

#053}@H_403_7@

猜你在找的React相关文章