I am doing research on file system performance, and I am stumped on how to create a very large file very quickly in C. Basically, I am trying to re-create a file system's folders and files by taking this metadata and storing it into a file. This is the extraction process. Later, I want to restore those folders and files into an existing freshly-made file system (in this case, ext3) using the metadata I previously extracted.
In the restore process, I have already succeeded in creating all the folders. However, I am a little confused on how to create the files instantly. For every file that I want to create, I have a file size and a file path. I am just confused on how to set the size of the file very quickly.
I used truncate, but this does not seem to affect the disk space usage from the point of view of the file system.
Thanks!
There is no way to do it instantly.
You need to have each block of the file written on disk and this is going to take a significant period of time, especially for a large file.