[lkml]   [2001]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectQ: sparse file creation in existing data?
Hi everybody,

though looking and grepping through the sources I couldn't find a way (via
fcntl() or whatever) to allow an existing file to get holes.

I found that cp has a parameter --sparse (or suchlike) - but strace shows
it doing a open(,O_TRUNC) which has a bit of impact on previous filedata :-)

What I'd like to do is something like

fh=open( ... , O_RDWR);
lseek(fh, position ,SEEK_START);
// where position is a multiple of fs block size

to create a 16kB hole in a file.
If the underlying fs doesn't support holes, I'd get ENOSYS or something.

What I'd like to use that for:

I imagine having a file on hd (eg. tar) and not enough space to decompress.
So with SOME space at least I'd open the file and stream it's data to tar,
after each few kB read I'd free some space - so this could eventually succeed.

I also thought about simple reversing the filedata - so I'd read off the
end of the file and truncate() downwards - but that would mean reversing
the whole file which could take some time on creation and would solve only
this specific case.

Ideas, anyone?



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:55    [W:0.065 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site