简体   繁体   中英

how to force windows FAT32 driver to reload FAT table?

i am implementing custom windows disk driver, and need FAT32 windows driver reloads it FAT tables, 1 and 2, that is below data sectors. How this can be done?

I need faster method without unmounting the drive. Why i am doing this is because the disk is memory virtual disk and the data is taken from the network in process of accessing sectors. I am writing directory data on-the-fly, it works, but not for the files - because at time driver fetches the FAT - the clusters are free, so files not work. I dissasembled fastfat.sys and found some points... At least i found device ioctl codes that maybe will reload fat table, i will post here if i got success.

Force the volume to be unmounted and remount it, or fake a device removal.

Also, why would you want to do this? This is almost certainly not something safe if you're trying to write to the filesystem at the same time as the OS is.

You should (well, must , really) unmount the drive before making any direct changes to the FAT, and then mount again to load those changes. Otherwise, you risk the possiblity of the OS overwriting the offline changes you've made using its (old) in-memory copy of the table, possibly corrupting your filesystem beyond repair.

You can start by calling DeviceIoControl with parameter FSCTL_LOCK_VOLUME. If it fails then you can be sure that you had better not modify the FAT yourself because other handles are open somewhere on the partition.

The next question is what to do when FSCTL_LOCK_VOLUME succeeds. Two people say to unmount the volume, but that is not enough. You have to take the volume offline, IOCTL_VOLUME_OFFLINE. But when I experimented, it still wasn't enough. Windows still had something buffered somewhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM