Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Aug 2019 11:00:41 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Alan Somers <asomers@freebsd.org>
Cc:        gljennjohn@gmail.com, Rick Macklem <rmacklem@uoguelph.ca>, "freebsd-current@FreeBSD.org" <freebsd-current@freebsd.org>
Subject:   Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
Message-ID:  <c4472ee6c3f0602c616be594158c5f658129a24a.camel@freebsd.org>
In-Reply-To: <CAOtMX2g=6cQdBpD2c7wS1ZaVFz08TDz-uauvCh_sS3VynLkR0g@mail.gmail.com>
References:  <YTBPR01MB3616B6F068199B6A3329432CDDD00@YTBPR01MB3616.CANPRD01.PROD.OUTLOOK.COM> <20190811090405.50cc49b1@ernst.home> <fe075daa384006c2056bb844cbccb6454c56fc3b.camel@freebsd.org> <CAOtMX2g=6cQdBpD2c7wS1ZaVFz08TDz-uauvCh_sS3VynLkR0g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 2019-08-11 at 09:12 -0600, Alan Somers wrote:
> On Sun, Aug 11, 2019 at 8:57 AM Ian Lepore <ian@freebsd.org> wrote:
> > 
> > On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote:
> > > On Sun, 11 Aug 2019 02:03:10 +0000
> > > Rick Macklem <rmacklem@uoguelph.ca> wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I've noticed that, if you do a lseek(SEEK_DATA/SEEK_HOLE) on a
> > > > file
> > > > that
> > > > resides in a file system that does not support holes, ENOTTY is
> > > > returned.
> > > > 
> > > > This error isn't listed for lseek() and seems a liitle weird.
> > > > 
> > > 
> > > ENOTTY is the standard error return for an unimplemented
> > > ioctl(2),
> > > and SEEK_HOLE ultimately becomes a call to fo_ioctl().
> > > 
> > > > I can see a couple of alternatives to this:
> > > > 1 - Return a different error. Maybe ENXIO?
> > > > or
> > > > 2 - Have lseek() do the trivial implementation when the
> > > > VOP_IOCTL()
> > > > fails.
> > > >    - For SEEK_DATA, just return the offset given as argument
> > > > and
> > > > for SEEK_HOLE
> > > >       return the file's size as the offset.
> > > > 
> > > > What do others think? rick
> > > > ps: The man page should be updated, whatever is done w.r.t.
> > > > this.
> > > > 
> > > 
> > > I also vote for option 2
> > > 
> > 
> > If SEEK_DATA and SEEK_HOLE don't return the standard "ioctl not
> > supported" error code and return a fake result, how are you
> > supposed to
> > determine at runtime whether SEEK_HOLE is supported or not?
> > 
> > -- Ian
> 
> pathconf(2) will tell you.
> 

Ahh, I wasn't aware of that.

For option 2, lseek() has to not just return the info, but must also
actually set the file position accordingly, and has to treat offset >=
filesize as an error.

-- Ian




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