阅读:3149回复:2
怎样移动NTFS的元文件数据,如$MFT和FAT32下的目录
不直接操作硬盘或分区数据,不用驱动,使用windows提供的API。
To defragment a file Use the FSCTL_GET_VOLUME_BITMAP control code to find a place on the volume that is large enough to accept an entire file. Note If necessary, move other files to make a place that is large enough. Ideally, there is enough unallocated clusters after the first extent of the file that you can move subsequent extents into the space after the first extent. Use the FSCTL_GET_RETRIEVAL_POINTERS control code to get a map of the current layout of the file on the disk. Walk the RETRIEVAL_POINTERS_BUFFER structure returned by FSCTL_GET_RETRIEVAL_POINTERS. Use the FSCTL_MOVE_FILE control code to move each cluster as you walk the structure. Note You may need to renew either the bitmap or the retrieval structure, or both at various times as other processes write to the disk. 我现在遇到的问题是: NTFS:普通文件、目录可以移动,但元数据移动不了,而且不知道怎么打开进行操作,比如$MFT等文件。 FAT32:文件可以移动,但目录移动不了,使用GetLastError返回87 另外我看微软有以下介绍,也就是说使用该API系列函数,在2000以后的版本是可以移动MFT的 The following list identifies the limitations of the file defragmentation API under Windows 2000, and they do not apply to later versions of Windows: The NTFS file system defragments data by using the system cache, therefore, encrypted files must be opened with read access. The NTFS file system defragments uncompressed files at the page boundary. The NTFS file system cannot defragment the master file table (MFT), re-parse points, bitmaps, and NTFS file system attribute lists. (主要是这句) The NTFS file system cannot defragment the space between the valid data length and the end of the file. For more information, see SetFileValidData. 多交流一下,如果有大虾能够指点一下就更好了,很急。 |
|
沙发#
发布于:2008-11-28 16:51
不清楚 想知道
|
|
板凳#
发布于:2008-12-02 23:33
这些元数据是底层文件系统管理的,个人认为动不了或难道较大。没必要动元数据吧。如$mft它是NTFS用来管理磁盘上文件的主要元数据之一,默认分配的印象中是20%的磁盘空间,它实际占用的是动态分配的,而且其未使用的空间在磁盘较满时会转换为剩余空间供普通文件使用……
几个月前在做透明加密驱动时将$objid一不小心把给加密了,哈哈导致启动时检测到索引错误N多的修复,不过没什么大问题,只是索引错误而已,建议不要动这类东西。真的要动先研究透NTFS的实现原理和源码吧。 在wdk的示例中有一个操作metadata的,可以参考研究一下。 |
|