Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 May 2007 15:45:09 -0500
From:      "Scot Hetzel" <swhetzel@gmail.com>
To:        emulation@freebsd.org
Subject:   linuxolator: LTP lseek03 failure
Message-ID:  <790a9fff0705021345j2ad9ae98o56aaf357d556fe27@mail.gmail.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
I have investigated the new LTP test failure for lseek03, and the
first test sets whence to 4 (SEEK_HOLE):

test 1 lseek(tfile_1554, 1, 4) Failed, errno=25 Inappropriate ioctl
for device, expected 22(EINVAL)

 I looked at linux lseek man page and it showed only the SEEK_SET,
SEEK_CUR, SEEK_END as valid values for whence.

I then did a search, and while I did find mailing list archives that
did have programmers trying to implement the SEEK_HOLE, SEEK_DATA
extentions to lseek.  But it hasn't been commited to the latest linux
kernel (linux-2.6.21.1 from kernel.org).

I have created a patch for lseek and llseek that limits whence to
SEEK_SET, SEEK_CUR, SEEK_END.

Scot
-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.

[-- Attachment #2 --]
--- compat/linux/linux_file.c-orig	Tue Apr 10 00:20:08 2007
+++ compat/linux/linux_file.c	Wed May  2 09:54:20 2007
@@ -230,25 +230,36 @@
 int
 linux_lseek(struct thread *td, struct linux_lseek_args *args)
 {
-
-    struct lseek_args /* {
-	int fd;
-	int pad;
-	off_t offset;
-	int whence;
-    } */ tmp_args;
-    int error;
+	struct lseek_args /* {
+	    int fd;
+	    int pad;
+	    off_t offset;
+	    int whence;
+	} */ bsd_args;
+	int error;
 
 #ifdef DEBUG
 	if (ldebug(lseek))
 		printf(ARGS(lseek, "%d, %ld, %d"),
 		    args->fdes, (long)args->off, args->whence);
 #endif
-    tmp_args.fd = args->fdes;
-    tmp_args.offset = (off_t)args->off;
-    tmp_args.whence = args->whence;
-    error = lseek(td, &tmp_args);
-    return error;
+	
+	bsd_args.fd = args->fdes;
+	bsd_args.offset = (off_t)args->off;
+	bsd_args.whence = args->whence;
+
+	/* linux only supports SEEK_SET, SEEK_CUR, SEEK_END */
+	switch(args->whence) {
+	case SEEK_SET:
+	case SEEK_CUR:
+	case SEEK_END:
+	    error = lseek(td, &bsd_args);
+	    break;
+	default:
+	    error = EINVAL;
+	}
+
+	return error;
 }
 
 int
@@ -269,7 +280,17 @@
 	bsd_args.offset = off;
 	bsd_args.whence = args->whence;
 
-	if ((error = lseek(td, &bsd_args)))
+	/* linux only supports SEEK_SET, SEEK_CUR, SEEK_END */
+	switch(args->whence) {
+	case SEEK_SET:
+	case SEEK_CUR:
+	case SEEK_END:
+	    error = lseek(td, &bsd_args);
+	    break;
+	default:
+	    error = EINVAL;
+	}
+	if (error)
 		return error;
 
 	if ((error = copyout(td->td_retval, args->res, sizeof (off_t))))
help

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