about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/i386
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-10-29 10:12:59 -0700
committerUlrich Drepper <drepper@redhat.com>2009-10-29 10:12:59 -0700
commit81c84bd9022328127f46d0484d254848911ea198 (patch)
treecf83570345f135db80dbf89a8439e0b46a70ef60 /sysdeps/unix/sysv/linux/i386
parentd9e8f9ec5557cc6ffcc154eafc4d2f2348df7b6b (diff)
downloadglibc-81c84bd9022328127f46d0484d254848911ea198.tar.gz
glibc-81c84bd9022328127f46d0484d254848911ea198.tar.xz
glibc-81c84bd9022328127f46d0484d254848911ea198.zip
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.
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r--sysdeps/unix/sysv/linux/i386/fcntl.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/fcntl.c b/sysdeps/unix/sysv/linux/i386/fcntl.c
index b27373d24b..5544d6e0d9 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);
     }