Date: Sun, 6 May 2007 12:05:27 -0500 From: "Scot Hetzel" <swhetzel@gmail.com> To: emulation@freebsd.org Subject: Re: linuxolator: LTP lseek03 failure Message-ID: <790a9fff0705061005v1a1a883ehc155bac7f747c3eb@mail.gmail.com> In-Reply-To: <790a9fff0705040819u24e4c2f0s5c9fc34b93770e13@mail.gmail.com> References: <790a9fff0705021345j2ad9ae98o56aaf357d556fe27@mail.gmail.com> <790a9fff0705040004oab16ed8q1a1c476386379ea9@mail.gmail.com> <20070504190007.Y37951@besplex.bde.org> <790a9fff0705040819u24e4c2f0s5c9fc34b93770e13@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
------=_Part_68362_20568820.1178471127029 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 5/4/07, Scot Hetzel <swhetzel@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. ------=_Part_68362_20568820.1178471127029 Content-Type: text/x-diff; name=vfs_syscalls.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_f1dpzvhs Content-Disposition: attachment; filename="vfs_syscalls.patch" SW5kZXg6IHZmc19zeXNjYWxscy5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZpbGU6IC9ob21lL25jdnMvc3Jj L3N5cy9rZXJuL3Zmc19zeXNjYWxscy5jLHYKcmV0cmlldmluZyByZXZpc2lvbiAxLjQzOApkaWZm IC11IC1yMS40MzggdmZzX3N5c2NhbGxzLmMKLS0tIHZmc19zeXNjYWxscy5jCTQgTWF5IDIwMDcg MTQ6MjM6MjggLTAwMDAJMS40MzgKKysrIHZmc19zeXNjYWxscy5jCTYgTWF5IDIwMDcgMTU6Mzc6 MzkgLTAwMDAKQEAgLTE3NTUsOSArMTc1NSwzNiBAQAogCQlicmVhazsKIAljYXNlIFNFRUtfREFU QToKIAkJZXJyb3IgPSBmb19pb2N0bChmcCwgRklPU0VFS0RBVEEsICZvZmZzZXQsIGNyZWQsIHRk KTsKKwkJaWYgKGVycm9yID09IEVOT1RUWSkgeworCQkJLyoKKwkJCSAqIFRoZSBpb2N0bCBpcyBu b3Qgc3VwcG9ydGVkLiBJcyB0aGUgb2Zmc2V0CisJCQkgKiBwYXN0IHRoZSBlbmQgb2YgdGhlIGZp bGUuCisJCQkgKi8KKwkJCWVycm9yID0gVk9QX0dFVEFUVFIodnAsICZ2YXR0ciwgZnAtPmZfY3Jl ZCwgdGQpOworCQkJaWYgKGVycm9yID09IDAgJiYKKwkJCSAgIChvZmZzZXQgPj0gKHVvZmZfdCl2 YXR0ci52YV9zaXplKSkKKwkJCQllcnJvciA9IEVOWElPOworCQl9CisJCWlmIChub25lZyAmJiAo b2Zmc2V0ID4gT0ZGX01BWCkpCisJCQllcnJvciA9IEVPVkVSRkxPVzsKIAkJYnJlYWs7CiAJY2Fz ZSBTRUVLX0hPTEU6CiAJCWVycm9yID0gZm9faW9jdGwoZnAsIEZJT1NFRUtIT0xFLCAmb2Zmc2V0 LCBjcmVkLCB0ZCk7CisJCWlmIChlcnJvciA9PSBFTk9UVFkpIHsKKwkJCS8qCisJCQkgKiBUaGUg aW9jdGwgaXMgbm90IHN1cHBvcnRlZC4gUmV0dXJuIHZpcnR1YWwKKwkJCSAqIGhvbGUgYXQgZW5k IG9mIGZpbGUsIGlmIG9mZnNldCBpcyB2YWxpZC4KKwkJCSAqLworCQkJZXJyb3IgPSBWT1BfR0VU QVRUUih2cCwgJnZhdHRyLCBmcC0+Zl9jcmVkLCB0ZCk7CisJCQlpZiAoZXJyb3IgPT0gMCkgewor CQkJCWlmICh1YXAtPm9mZnNldCA8IChvZmZfdCl2YXR0ci52YV9zaXplKQorCQkJCQlvZmZzZXQg PSAodW9mZl90KXZhdHRyLnZhX3NpemU7CisJCQkJZWxzZQorCQkJCQllcnJvciA9IEVOWElPOwor CQkJfQorCQl9CisJCWlmIChub25lZyAmJiAob2Zmc2V0ID4gT0ZGX01BWCkpCisJCQllcnJvciA9 IEVPVkVSRkxPVzsKIAkJYnJlYWs7CiAJZGVmYXVsdDoKIAkJZXJyb3IgPSBFSU5WQUw7Cg== ------=_Part_68362_20568820.1178471127029--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0705061005v1a1a883ehc155bac7f747c3eb>