Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Apr 2024 13:54:01 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Alan Somers <asomers@freebsd.org>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: SEEK_HOLE at EOF
Message-ID:  <202404051354.435Ds1KX086243@critter.freebsd.dk>
In-Reply-To: <CAOtMX2hfxQNrk1iPtq6snYnt0EzK_ffXm5b1TnkTLCYKgW6j3A@mail.gmail.com>
References:  <CAOtMX2gaHkH7gRT1OWTNpZEcr13%2BiozicmUDZ1hEapT6oiXiuQ@mail.gmail.com> <202404050543.4355hDcS009860@critter.freebsd.dk> <CAOtMX2hfxQNrk1iPtq6snYnt0EzK_ffXm5b1TnkTLCYKgW6j3A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--------
Alan Somers writes:
> On Thu, Apr 4, 2024 at 11:43=E2=80=AFPM Poul-Henning Kamp <phk@phk.freebsd.=
> dk> wrote:

> > Just two minor quibbles:
> >
> > If the file position is EOF, then you /are/ "beyond the end of the file"
> > because a read(2) would not be able to return any data.
>
> Do you distinguish between "at EOF" and "beyond EOF"?  And does it not
> trouble you that calling SEEK_HOLE from the beginning of the "virtual
> hole at EOF" will return ENXIO, even though calling SEEK_HOLE from the
> beginning of any real hole will return the current offset?

EOF is where the file ends and there's no "hole" there, because there
no more file on the other side of that "hole".

When you stand on a cliff, the ocean is not "a hole in the landscape",
it's where the landscape ends.

> > And returning ENXIO is more informative than returning the size of the
> > file, since it atomically tells you that there are no more holes.
>
> Ahh, that's a good point.  It's the first point I've heard in favor of
> this option.  Are you aware of any applications that need to know
> that?

No, but that should not get in the way of good syscall architecture :-)

It might be useful for archivers which try to be smart about sparse files.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404051354.435Ds1KX086243>