mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Linus <torvalds@transmeta.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	anton@samba.org, "David S. Miller" <davem@redhat.com>,
	ak@muc.de, davidm@hpl.hp.com, schwidefsky@de.ibm.com,
	ralf@gnu.org, matthew@wil.cx
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part
Date: Tue, 11 Mar 2003 11:41:13 +1100	[thread overview]
Message-ID: <20030311114113.44abed66.sfr@canb.auug.org.au> (raw)

Hi Linus,

This patch creates compat_sys_fcntl{,64}.  The diffstat for the whole
patch set is below, but this is just the generic part, the architecture
specific parts will follow.

This patch also removes struct flock64 from all the 64 bit architectures
(except parisc).

I think I have answered all the questions from the last time I posted
this, so please apply.

 arch/ia64/ia32/ia32_entry.S       |    4 -
 arch/ia64/ia32/sys_ia32.c         |   92 -----------------------
 arch/mips64/kernel/linux32.c      |   44 -----------
 arch/mips64/kernel/scall_o32.S    |    4 -
 arch/parisc/kernel/sys_parisc32.c |   51 -------------
 arch/parisc/kernel/syscall.S      |    5 -
 arch/ppc64/kernel/misc.S          |    4 -
 arch/ppc64/kernel/sys_ppc32.c     |   33 --------
 arch/s390x/kernel/entry.S         |    4 -
 arch/s390x/kernel/linux32.c       |   51 -------------
 arch/s390x/kernel/linux32.h       |    4 -
 arch/s390x/kernel/wrapper32.S     |   12 +--
 arch/sparc64/kernel/sys_sparc32.c |   35 ---------
 arch/sparc64/kernel/systbls.S     |    6 -
 arch/x86_64/ia32/ia32entry.S      |    4 -
 arch/x86_64/ia32/sys_ia32.c       |   96 ------------------------
 fs/compat.c                       |  147 ++++++++++++++++++++++++++++++--------
 include/asm-alpha/fcntl.h         |    3 
 include/asm-ia64/compat.h         |   19 ++++
 include/asm-ia64/fcntl.h          |    5 -
 include/asm-ia64/ia32.h           |    4 -
 include/asm-mips64/compat.h       |   18 ++++
 include/asm-mips64/fcntl.h        |   10 --
 include/asm-parisc/compat.h       |   11 ++
 include/asm-ppc64/compat.h        |   16 +++-
 include/asm-ppc64/fcntl.h         |   13 ---
 include/asm-s390x/compat.h        |   16 +++-
 include/asm-s390x/fcntl.h         |    2 
 include/asm-sparc64/compat.h      |   16 ++++
 include/asm-sparc64/fcntl.h       |   11 --
 include/asm-x86_64/compat.h       |   19 ++++
 include/asm-x86_64/fcntl.h        |    4 -
 include/asm-x86_64/ia32.h         |   12 ---
 include/linux/compat.h            |    3 
 include/linux/fs.h                |    2 
 35 files changed, 255 insertions(+), 525 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/fs/compat.c 2.5.64-2003030918-32bit.2/fs/compat.c
--- 2.5.64-2003030918-32bit.1/fs/compat.c	2003-01-14 09:57:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/fs/compat.c	2003-03-09 20:34:45.000000000 +1100
@@ -75,36 +75,6 @@
 	return error;
 }
 
-int get_compat_flock(struct flock *kfl, struct compat_flock *ufl)
-{
-	int err;
-
-	if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)))
-		return -EFAULT;
-
-	err = __get_user(kfl->l_type, &ufl->l_type);
-	err |= __get_user(kfl->l_whence, &ufl->l_whence);
-	err |= __get_user(kfl->l_start, &ufl->l_start);
-	err |= __get_user(kfl->l_len, &ufl->l_len);
-	err |= __get_user(kfl->l_pid, &ufl->l_pid);
-	return err;
-}
-
-int put_compat_flock(struct flock *kfl, struct compat_flock *ufl)
-{
-	int err;
-
-	if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)))
-		return -EFAULT;
-
-	err = __put_user(kfl->l_type, &ufl->l_type);
-	err |= __put_user(kfl->l_whence, &ufl->l_whence);
-	err |= __put_user(kfl->l_start, &ufl->l_start);
-	err |= __put_user(kfl->l_len, &ufl->l_len);
-	err |= __put_user(kfl->l_pid, &ufl->l_pid);
-	return err;
-}
-
 static int put_compat_statfs(struct compat_statfs *ubuf, struct statfs *kbuf)
 {
 	if (verify_area(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
@@ -159,3 +129,120 @@
 out:
 	return error;
 }
+
+static int get_compat_flock(struct flock *kfl, struct compat_flock *ufl)
+{
+	if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
+	    __get_user(kfl->l_type, &ufl->l_type) ||
+	    __get_user(kfl->l_whence, &ufl->l_whence) ||
+	    __get_user(kfl->l_start, &ufl->l_start) ||
+	    __get_user(kfl->l_len, &ufl->l_len) ||
+	    __get_user(kfl->l_pid, &ufl->l_pid))
+		return -EFAULT;
+	return 0;
+}
+
+static int put_compat_flock(struct flock *kfl, struct compat_flock *ufl)
+{
+	if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
+	    __put_user(kfl->l_type, &ufl->l_type) ||
+	    __put_user(kfl->l_whence, &ufl->l_whence) ||
+	    __put_user(kfl->l_start, &ufl->l_start) ||
+	    __put_user(kfl->l_len, &ufl->l_len) ||
+	    __put_user(kfl->l_pid, &ufl->l_pid))
+		return -EFAULT;
+	return 0;
+}
+
+static int get_compat_flock64(struct flock *kfl, struct compat_flock64 *ufl)
+{
+	if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
+	    __get_user(kfl->l_type, &ufl->l_type) ||
+	    __get_user(kfl->l_whence, &ufl->l_whence) ||
+	    __get_user(kfl->l_start, &ufl->l_start) ||
+	    __get_user(kfl->l_len, &ufl->l_len) ||
+	    __get_user(kfl->l_pid, &ufl->l_pid))
+		return -EFAULT;
+	return 0;
+}
+
+static int put_compat_flock64(struct flock *kfl, struct compat_flock64 *ufl)
+{
+	if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
+	    __put_user(kfl->l_type, &ufl->l_type) ||
+	    __put_user(kfl->l_whence, &ufl->l_whence) ||
+	    __put_user(kfl->l_start, &ufl->l_start) ||
+	    __put_user(kfl->l_len, &ufl->l_len) ||
+	    __put_user(kfl->l_pid, &ufl->l_pid))
+		return -EFAULT;
+	return 0;
+}
+
+extern asmlinkage long sys_fcntl(unsigned int, unsigned int, unsigned long);
+
+asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
+		unsigned long arg)
+{
+	mm_segment_t old_fs;
+	struct flock f;
+	long ret;
+
+	switch (cmd) {
+	case F_GETLK:
+	case F_SETLK:
+	case F_SETLKW:
+		ret = get_compat_flock(&f, (struct compat_flock *)arg);
+		if (ret != 0)
+			break;
+		old_fs = get_fs();
+		set_fs(KERNEL_DS);
+		ret = sys_fcntl(fd, cmd, (unsigned long)&f);
+		set_fs(old_fs);
+		if ((cmd == F_GETLK) && (ret == 0)) {
+			if ((f.l_start >= COMPAT_OFF_T_MAX) ||
+			    ((f.l_start + f.l_len) >= COMPAT_OFF_T_MAX))
+				ret = -EOVERFLOW;
+			if (ret == 0)
+				ret = put_compat_flock(&f,
+						(struct compat_flock *)arg);
+		}
+		break;
+
+	case F_GETLK64:
+	case F_SETLK64:
+	case F_SETLKW64:
+		ret = get_compat_flock64(&f, (struct compat_flock64 *)arg);
+		if (ret != 0)
+			break;
+		old_fs = get_fs();
+		set_fs(KERNEL_DS);
+		ret = sys_fcntl(fd, F_GETLK, (unsigned long)&f);
+		ret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :
+				((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
+				(unsigned long)&f);
+		set_fs(old_fs);
+		if ((cmd == F_GETLK64) && (ret == 0)) {
+			if ((f.l_start >= COMPAT_LOFF_T_MAX) ||
+			    ((f.l_start + f.l_len) >= COMPAT_LOFF_T_MAX))
+				ret = -EOVERFLOW;
+			if (ret == 0)
+				ret = put_compat_flock64(&f,
+						(struct compat_flock64 *)arg);
+		}
+		break;
+
+	default:
+		ret = sys_fcntl(fd, cmd, arg);
+		break;
+	}
+	return ret;
+}
+
+asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
+		unsigned long arg)
+{
+	if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
+		return -EINVAL;
+	return compat_sys_fcntl64(fd, cmd, arg);
+}
+
diff -ruN 2.5.64-2003030918-32bit.1/include/linux/compat.h 2.5.64-2003030918-32bit.2/include/linux/compat.h
--- 2.5.64-2003030918-32bit.1/include/linux/compat.h	2003-01-17 14:01:07.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/linux/compat.h	2003-03-09 20:34:45.000000000 +1100
@@ -10,7 +10,6 @@
 
 #include <linux/stat.h>
 #include <linux/param.h>	/* for HZ */
-#include <linux/fcntl.h>	/* for struct flock */
 #include <asm/compat.h>
 
 #define compat_jiffies_to_clock_t(x)	\
@@ -40,8 +39,6 @@
 } compat_sigset_t;
 
 extern int cp_compat_stat(struct kstat *, struct compat_stat *);
-extern int get_compat_flock(struct flock *, struct compat_flock *);
-extern int put_compat_flock(struct flock *, struct compat_flock *);
 extern int get_compat_timespec(struct timespec *, struct compat_timespec *);
 extern int put_compat_timespec(struct timespec *, struct compat_timespec *);
 
diff -ruN 2.5.64-2003030918-32bit.1/include/linux/fs.h 2.5.64-2003030918-32bit.2/include/linux/fs.h
--- 2.5.64-2003030918-32bit.1/include/linux/fs.h	2003-03-09 20:09:18.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/linux/fs.h	2003-03-09 20:34:45.000000000 +1100
@@ -526,8 +526,10 @@
 extern int fcntl_getlk(struct file *, struct flock *);
 extern int fcntl_setlk(struct file *, unsigned int, struct flock *);
 
+#if BITS_PER_LONG == 32
 extern int fcntl_getlk64(struct file *, struct flock64 *);
 extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 *);
+#endif
 
 /* fs/locks.c */
 extern void locks_init_lock(struct file_lock *);

             reply	other threads:[~2003-03-11  0:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-11  0:41 Stephen Rothwell [this message]
2003-03-11  0:47 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 2/9 ppc64 part Stephen Rothwell
2003-03-11  0:50 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 3/9 sparc64 part Stephen Rothwell
2003-03-11 23:42   ` David S. Miller
2003-03-12  4:51     ` Anton Blanchard
2003-03-11  0:52 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 4/9 x86_64 part Stephen Rothwell
2003-03-11  0:54 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 5/9 ia64 part Stephen Rothwell
2003-03-11  0:57 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 6/9 s390x part Stephen Rothwell
2003-03-11  0:59 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 7/9 mips64 part Stephen Rothwell
2003-03-11  1:01 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 8/9 parisc part Stephen Rothwell
2003-03-11  1:08 ` [PATCH][COMPAT] compat_sys_fcntl{,64} 9/9 Aalpha part Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2003-03-11 12:20 [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part Martin Schwidefsky
2003-03-12  4:44 ` Stephen Rothwell
2003-03-12  5:02   ` Linus Torvalds
2003-03-12  5:22     ` Stephen Rothwell
2003-03-12  5:26       ` Linus Torvalds
2003-03-12  5:57         ` Stephen Rothwell
2003-03-12 11:46         ` David S. Miller
2003-03-10 12:43 Arnd Bergmann
2003-03-04  5:58 Stephen Rothwell
2003-02-28  9:50 sfr
2003-02-28 10:36 ` Andi Kleen
2003-03-01  9:12   ` Anton Blanchard
2003-02-28  4:33 Stephen Rothwell
2003-02-28  8:08 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030311114113.44abed66.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=ak@muc.de \
    --cc=anton@samba.org \
    --cc=davem@redhat.com \
    --cc=davidm@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=ralf@gnu.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®