Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-17-2005, 02:12 AM   #1
LQ Newbie
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
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.

Old 08-17-2005, 07:29 PM   #2
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Low disk space, problem deleting files gtzpower Linux - Software 1 05-24-2005 09:57 PM
rm'ing files doesn't free up disk space Earlw Fedora 4 03-06-2005 06:40 PM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 03:58 PM
what files can be safely deleted to save disk space? rohan208 Linux - General 9 05-27-2004 08:06 PM
Disk space wastage 73 GB Hard disk rajgopalhg Linux - Hardware 2 10-18-2002 03:41 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration