diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/bits/fcntl.h | 25 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/fcntl.c | 29 |
2 files changed, 50 insertions, 4 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 35dfb299d2..6a38dc03fe 100644 --- a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -85,13 +85,15 @@ #define F_SETLKW64 14 /* Set record locking info (blocking). */ #if defined __USE_BSD || defined __USE_UNIX98 -# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */ -# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */ +# define F_SETOWN 8 /* Get owner (process receiving SIGIO). */ +# define F_GETOWN 9 /* Set owner (process receiving SIGIO). */ #endif #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ +# define F_SETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU @@ -166,6 +168,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD 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); } |