F_FREESP argument to fcntl() (was: Re: sparse files)

Pim Zandbergen pim at cti-software.nl
Mon Dec 11 03:19:52 AEST 1989


guy at auspex.auspex.com (Guy Harris) writes:

>>Once an area of a file is written,
>>it cannot be returned to its previous sparse state.

>Not in general, anyway.  At least the first version of AIX for the RT PC
>claimed, in its documentation, that it had an "fclear()" call to punch
>holes in files; I think this may show up in future releases of other
>UNIXes as well.

I think the *undocumented* F_FREESP argument to fcntl()
in lots of versions of SYSVR3 can do this too.
Take a look in /usr/include/sys/fcntl.h to find out if yours has it.

Some time ago somebody posted a SYSV implementation of
ftruncate(). It used F_FREESP to chop off the end of a file.
But I see no reason why it could not be used to punch 
a hole in the middle of a file.

Can anybody confirm this? This could be the base of a handy
tool able to free LOTS of disk space.

-- 
Pim Zandbergen                           domain : pim at cti-software.nl
CTI Software BV                          uucp   : uunet!mcsun!hp4nl!ctisbv!pim
Laan Copes van Cattenburch 70            phone  : +31 70 3542302
2585 GD The Hague, The Netherlands       fax    : +31 70 3512837



More information about the Comp.unix.questions mailing list