Why does fsutil.exe take less time to write a huge file to disk than programmatically?

this question fits this topic: creating a huge dummy file in seconds in C #

I just checked the fsutil.exe file in xp / vista / seven to write a huge amount of dummy data to the storage drive, and it takes less time to create such a large file compared to the programmatic way.

when I try to do the same with .net, it will take significantly longer than fsutil.exe

note: I know that .net does not use bcuz native code, that I just checked this problem with native api as well as follows:

long int size = DiskFree('L' - 64);
const char* full = "fulldisk.dsk";
__try{
Application->ProcessMessages();
HANDLE hf = CreateFile(full,
                       GENERIC_WRITE,
                       0,
                       0,
                       CREATE_ALWAYS,
                       0,
                       0);
SetFilePointer(hf, size, 0, FILE_BEGIN);
SetEndOfFile(hf);
CloseHandle(hf);
}__finally{
    ShowMessage("Finished");
    exit(0);

and the answer was equal to .net results.

fsutil.exe , , .net- , 2 : 400mb .net ~ 40 fsutil.exe 20 .

- ? fsutil.exe , ?

+3
4

, fsutil, , , , ( , ).

, .

:

+5

. - IRP_MJ_WRITE IRP . cmd win32-, , . "fsutil file createnew...", . win2k8 r2 NTFS. ( , 100%), . , MFT - . fsutil , , , 1.

sening FSCTL_GET_RETRIEVAL_POINTERS , . ,

+2

  • ( )
  • C/++
  • , - , .

- , .NET-, (Ok, , - , , ).

, C/++. , Assembler.

- .NET. , , , , , Microsoft , , .

Hope this answers your question, Best regards, Tom.

+1
source

fsutil only works on NTFS and exFAT, not FAT32, FAT16. This is due to the fact that some file systems have an “initialized size” and thus support quick file initialization. This simply reserves the clusters, but does not nullify them, because it is noted in the file system that no data was written to the file, and valid reads will return filled with 00 buffers.

+1
source

Source: https://habr.com/ru/post/1725474/


All Articles