LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   reserving space on the disk for sparse files (http://www.linuxquestions.org/questions/programming-9/reserving-space-on-the-disk-for-sparse-files-354114/)

madhukirant 08-17-2005 03:12 AM

reserving space on the disk for sparse files
 
HI All,
Currently i am using SLES9 and i am creating sparse files using "dd" system call. However i need to reserve space for these sparse files on the disk. Earlier i used "XFS_IOC_RESVSP64" ioctl flag to reserve space for a sparse file on XFS. I would apprecitate if anyone can give me a similar way to reserve space for a sparse file on either ext3/reiserfs.


PS: i have tried populating the file with characters for every 512/4096 bytes but it takes lot of time as the file size grows.... approximately 10 minutes for a 15GB file. i need to reserve space in minimum time possible.

thanks
Madhu

primo 08-17-2005 08:29 PM

what's that dd system call? :s
sparse files (files with holes) are supposed to save disk space by not using it for a contiguous buffer of zero bytes.

One strategy you may use is to lseek() X-1 bytes and then write a '\0' for a file that will have X bytes.
ftruncate() may be used too to extend a file but these semantics are not the same on every OS


All times are GMT -5. The time now is 03:27 PM.