From owner-freebsd-emulation@FreeBSD.ORG Sun May 6 17:05:28 2007 Return-Path: X-Original-To: emulation@freebsd.org Delivered-To: freebsd-emulation@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 07A3316A400 for ; Sun, 6 May 2007 17:05:28 +0000 (UTC) (envelope-from swhetzel@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.250]) by mx1.freebsd.org (Postfix) with ESMTP id B4D0D13C44C for ; Sun, 6 May 2007 17:05:27 +0000 (UTC) (envelope-from swhetzel@gmail.com) Received: by an-out-0708.google.com with SMTP id d23so61719and for ; Sun, 06 May 2007 10:05:27 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=F6wAm9axs5p0UThRRhz2OwUB39wVOwGXLGWfENHIkFqxv6WrCVdJ2ixSX7Vn078GVuhP+l2NoZpEZDV9PI9gDfGySjddCTg/9ifqTArHlSN916ACCddCMmdA+HiC7ezZMFlCm1t158Tfsfd/dFD9vIqHO6NLDceJEwSL8o9OLQ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=tyLtBA2rIHKkA4CQuNCvws3uPhdf489G0+bh7UwJ+ovMIEW6hS8l5GYXNrczY0F+nLkD9NO6Whn9UWdXNhWIdvG6lmAaYVRXObhUak8FxpdfYawK19TwUhPPO4px3kMec26FlDc3ptiGSewaY0Epe3sWCFHY2I4RqL1Mw7yjvDY= Received: by 10.100.8.18 with SMTP id 18mr936860anh.1178471127111; Sun, 06 May 2007 10:05:27 -0700 (PDT) Received: by 10.100.139.10 with HTTP; Sun, 6 May 2007 10:05:27 -0700 (PDT) Message-ID: <790a9fff0705061005v1a1a883ehc155bac7f747c3eb@mail.gmail.com> Date: Sun, 6 May 2007 12:05:27 -0500 From: "Scot Hetzel" To: emulation@freebsd.org In-Reply-To: <790a9fff0705040819u24e4c2f0s5c9fc34b93770e13@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_68362_20568820.1178471127029" References: <790a9fff0705021345j2ad9ae98o56aaf357d556fe27@mail.gmail.com> <790a9fff0705040004oab16ed8q1a1c476386379ea9@mail.gmail.com> <20070504190007.Y37951@besplex.bde.org> <790a9fff0705040819u24e4c2f0s5c9fc34b93770e13@mail.gmail.com> Cc: Subject: Re: linuxolator: LTP lseek03 failure X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2007 17:05:28 -0000 ------=_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 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 YXR0ci52Y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