Re: Is there a "make hole" (truncate in middle) syscall?

Szakacsits Szabolcs
2003-12-05T00:34:04Z

On Thu, 4 Dec 2003, Rob Landley wrote:
> > Depends what you do, what fs you use. Using XFS XFS_IOC_GETBMAPX you might
> > get a huge improvement, see e.g. some numbers,
> >
> > http://marc.theaimsgroup.com/?l=reiserfs&m=105827549109079&w=2
> >
> > The problem is, 0 general purpose (like cp, tar, cat, etc) util supports
> > it, you have to code your app accordingly.
>
> Okay, I'll bite. How would one go about adding hole support to cat? :)

As I wrote above, for XFS use XFS_IOC_GETBMAPX and read only the blocks in
use from the disk and dump a preallocated buffer filled with zeros for the
holes.

For other filesytems you should use FIBMAP but it's so inefficient,
limited, etc that probably it's not worth doing because in general you
would end up being slower.

Szaka