linuxolator: LTP lseek03 failure
Scot Hetzel
swhetzel at gmail.com
Sun May 6 17:05:28 UTC 2007
On 5/4/07, Scot Hetzel <swhetzel at gmail.com> wrote:
> > The main bug is in the implementation of SEEK_HOLE and SEEK_DATA. This
> > uses fo_ioctl() and fo_ioctl() returns ENOTTY if the file system doesn't
> > support these seeks, but ENOTTY (Inappropriate ioctl for device) is a
> > very inappropriate errno for a syscall that is not ioctl(), especially
> > on a file that is not a device. POSIX requires EINVAL if the `whence'
> > arg is not a standard POSIX one, and I think ENOTTY should be translated
> > to this.
> >
>
> I see three places where this could be fixed:
>
> kern/vfs_vnops.c:vn_ioctl(...)
> kern/vfs_syscalls.c:lseek(...)
> compat/linux/linux_file.c:(linux_lseek and linux_llseek)
>
> Would the best fix be to change the native lseek to return EINVAL when
> fo_ioctl returns ENOTTY?
>
I had a look at the OpenSolaris implementation of lseek and found that
we are returning the wrong error code for the ENOTTY case. When
ENOTTY is returned by fo_ioctl, we should be checking for the
following cases:
SEEK_DATA - Is offset past end of file
SEEK_HOLE - Return virtual hole at end of file, if offset is valid
on error, SEEK_DATA and SEEK_HOLE should be returning ENXIO for these
cases. OpenSolaris also checks offset > OFF_MAX, and returns
EOVERFLOW.
When the lseek03 test is run, with these changes, it returns with ENXIO.
I sent the attached patch for kern/vfs_syscalls.c to pjd for review.
Scot
--
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vfs_syscalls.patch
Type: text/x-diff
Size: 1248 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-emulation/attachments/20070506/0832e761/vfs_syscalls.bin
More information about the freebsd-emulation
mailing list