This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.10-371-g81c84bd
- From: drepper at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 29 Oct 2009 17:14:16 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.10-371-g81c84bd
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 81c84bd9022328127f46d0484d254848911ea198 (commit)
from d9e8f9ec5557cc6ffcc154eafc4d2f2348df7b6b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=81c84bd9022328127f46d0484d254848911ea198
commit 81c84bd9022328127f46d0484d254848911ea198
Author: Ulrich Drepper <drepper@redhat.com>
Date: Thu Oct 29 10:12:59 2009 -0700
Fix F_GETOWN on some Linux archs.
The syscall conventions on some Linux archs prevented F_GETOWN from working
correctly in some situations. This can be rectified when using the new
F_GETOWN_EX command.
diff --git a/ChangeLog b/ChangeLog
index 4ad5929..a54bc10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2009-10-29 Ulrich Drepper <drepper@redhat.com>
+ [BZ #10840]
+ * sysdeps/unix/sysv/linux/kernel-features.h: Define
+ __ASSUME_F_GETOWN_EX.
+ * sysdeps/unix/sysv/linux/fcntl.c: Implement F_GETOWN using F_GETOWN_EX
+ if possible.
+ * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
+
* sysdeps/unix/sysv/linux/sh/bits/fcntl.h: Define F_OWNER_*
and f_owner_ex.
* sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h: Likewise.
diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c
index 1f5aca1..b19654c 100644
--- a/sysdeps/unix/sysv/linux/fcntl.c
+++ b/sysdeps/unix/sysv/linux/fcntl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,40 @@
#include <stdarg.h>
#include <sys/syscall.h>
+#include <kernel-features.h>
+
+
+#ifdef __ASSUME_F_GETOWN_EX
+# define miss_F_GETOWN_EX 0
+#else
+static int miss_F_GETOWN_EX;
+#endif
+
+
+static int
+do_fcntl (int fd, int cmd, void *arg)
+{
+ if (cmd != F_GETOWN || miss_F_GETOWN_EX)
+ return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+
+ INTERNAL_SYSCALL_DECL (err);
+ struct f_owner_ex fex;
+ int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex);
+ if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+ return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
+
+#ifndef __ASSUME_F_GETOWN_EX
+ if (INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
+ {
+ res = INLINE_SYSCALL (fcntl, 3, fd, F_GETOWN, arg);
+ miss_F_GETOWN_EX = 1;
+ return res;
+ }
+#endif
+
+ __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
+ return -1;
+}
#ifndef NO_CANCELLATION
@@ -36,7 +70,7 @@ __fcntl_nocancel (int fd, int cmd, ...)
arg = va_arg (ap, void *);
va_end (ap);
- return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+ return do_fcntl (fd, cmd, arg);
}
#endif
@@ -52,11 +86,11 @@ __libc_fcntl (int fd, int cmd, ...)
va_end (ap);
if (SINGLE_THREAD_P || cmd != F_SETLKW)
- return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+ return do_fcntl (fd, cmd, arg);
int oldtype = LIBC_CANCEL_ASYNC ();
- int result = INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+ int result = do_fcntl (fd, cmd, arg);
LIBC_CANCEL_RESET (oldtype);
diff --git a/sysdeps/unix/sysv/linux/i386/fcntl.c b/sysdeps/unix/sysv/linux/i386/fcntl.c
index b27373d..5544d6e 100644
--- a/sysdeps/unix/sysv/linux/i386/fcntl.c
+++ b/sysdeps/unix/sysv/linux/i386/fcntl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000,2002,2003,2004,2006 Free Software Foundation, Inc.
+/* Copyright (C) 2000,2002,2003,2004,2006,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -30,6 +30,13 @@
int __have_no_fcntl64;
#endif
+#ifdef __ASSUME_F_GETOWN_EX
+# define miss_F_GETOWN_EX 0
+#else
+static int miss_F_GETOWN_EX;
+#endif
+
+
#if defined NO_CANCELLATION && __ASSUME_FCNTL64 == 0
# define __fcntl_nocancel __libc_fcntl
#endif
@@ -119,6 +126,26 @@ __fcntl_nocancel (int fd, int cmd, ...)
assert (F_SETLK - F_SETLKW == F_SETLK64 - F_SETLKW64);
return INLINE_SYSCALL (fcntl, 3, fd, cmd + F_SETLK - F_SETLK64, &fl);
}
+ case F_GETOWN:
+ if (! miss_F_GETOWN_EX)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ struct f_owner_ex fex;
+ int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex);
+ if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+ return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
+
+#ifndef __ASSUME_F_GETOWN_EX
+ if (INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
+ miss_F_GETOWN_EX = 1;
+ else
+#endif
+ {
+ __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
+ return -1;
+ }
+ }
+ /* FALLTHROUGH */
default:
return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
}
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index ff065ef..f48e644 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -542,3 +542,8 @@
# define __ASSUME_PREADV 1
# define __ASSUME_PWRITEV 1
#endif
+
+/* Support for F_GETOWN_EX was introduced in 2.6.32. */
+#if __LINUX_KERNEL_VERSION >= 0x020620
+# define __ASSUME_F_GETOWN_EX 1
+#endif
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++
sysdeps/unix/sysv/linux/fcntl.c | 42 ++++++++++++++++++++++++++---
sysdeps/unix/sysv/linux/i386/fcntl.c | 29 +++++++++++++++++++-
sysdeps/unix/sysv/linux/kernel-features.h | 5 +++
4 files changed, 78 insertions(+), 5 deletions(-)
hooks/post-receive
--
GNU C Library master sources