NtCreateFile() doesn’t do anything special with the argument, it simply passes it on to the file system driver in the MJ_CREATE request. You’ll need the WDK to see how it is getting used. A good one to look at is the FAT driver, you’ll find the AllocationSize used in src/filesys/fastfat/w2k/create.c. Follow the call chain into allocsup.c, FatAllocateDiskSpace().
Opportunities abound with knowing the expected allocation size up front. It can allocate the clusters up front with the disk drive head is already in the right spot to update the file allocation table. And it can fail the create call when the volume is running low on space before consuming every available cluster. Conversely, having it not fail will ensure that you can write to the file without running out of disk space. As long as you don’t write more than you asked for anyway.
And sure, when you close the file then the file size will be updated to the actual number of bytes written. AllocationSize is merely a hint.






Leave a comment