Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
Ian Lepore wrote: >On Sun, 2019-08-11 at 09:12 -0600, Alan Somers wrote: >> On Sun, Aug 11, 2019 at 8:57 AM Ian Lepore wrote: >> > >> > On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote: >> > > On Sun, 11 Aug 2019 02:03:10 + >> > > Rick Macklem 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. I have put a patch for this at https://reviews.freebsd.org/D21299 I listed markj@ as a reviewer, but anyone is welcome to review it, if they'd like. Since vn_bmap_seekhole() can return ENOTTY, the above patch follows that convention as well. I also have a trivial patch to map errnos not specified for lseek() to EINVAL. https://reviews.freebsd.org/D21300. Ditto above w.r.t. to reviewing it. rick ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
Ian Lepore wrote: >On Sun, 2019-08-11 at 09:12 -0600, Alan Somers wrote: >> On Sun, Aug 11, 2019 at 8:57 AM Ian Lepore wrote: >> > >> > On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote: >> > > On Sun, 11 Aug 2019 02:03:10 + >> > > Rick Macklem 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(). That's true and explains why it returns ENOTTY. However, lseek(2) is not ioctl(2) and it doesn't list ENOTTY as an error. (Just to make things confusing, lseek(2) using SEEK_DATA/SEEK_HOLE appears to be only a POSIX draft at this point, so POSIX doesn't really help w.r.t. what errors should be returned for this case.) >> > > >> > > > 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. Yes, this check is done below the VOP_IOCTL() layer for the file system (using vn_bmap_seekhole() or custom code). I think the easiest way to implement #2 is create a vop_stdioctl() and put it into sys/kern/vfs_default.c. It would need to do this check. Interestingly, I had assumed the discussion would have been between leaving the errno alone vs changing the errno. I only threw in #2 for completeness sake. --> Now, it appears that #2 is the favourite. I'll wait for more responses before I propose a patch. Thanks for the comments, rick ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
On Sun, 2019-08-11 at 09:12 -0600, Alan Somers wrote: > On Sun, Aug 11, 2019 at 8:57 AM Ian Lepore wrote: > > > > On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote: > > > On Sun, 11 Aug 2019 02:03:10 + > > > Rick Macklem 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 ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
On Sun, 11 Aug 2019 08:57:04 -0600 Ian Lepore wrote: > On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote: > > On Sun, 11 Aug 2019 02:03:10 + > > Rick Macklem 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? > My understanding of what Rick wrote was that, upon receiving ENOTTY from the ioctl, lseek() would simply do what he described in (2). His wording seems perfectly clear to me. -- Gary Jennejohn ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
On Sun, Aug 11, 2019 at 8:57 AM Ian Lepore wrote: > > On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote: > > On Sun, 11 Aug 2019 02:03:10 + > > Rick Macklem 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. ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
On Sun, 2019-08-11 at 09:04 +0200, Gary Jennejohn wrote: > On Sun, 11 Aug 2019 02:03:10 + > Rick Macklem 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 ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
On Sun, 11 Aug 2019 02:03:10 + Rick Macklem 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 -- Gary Jennejohn ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
On Sat, Aug 10, 2019 at 8:03 PM Rick Macklem 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. > > 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. I vote option 2. > > What do others think? rick > ps: The man page should be updated, whatever is done w.r.t. this. ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
RFC: should lseek(SEEK_DATA/SEEK_HOLE) return ENOTTY?
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. 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. ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"