diff options
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/common/.cvsignore | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/Makefile | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/accept4.c | 49 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/bits/socket.h | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/eventfd.c | 15 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/grantpt.c | 13 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/accept4.S | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/internal_accept4.S | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/internal_accept4.S | 14 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/net/if_arp.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/signalfd.c | 15 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/socketcall.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sparc/bits/socket.h | 16 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sys/epoll.h | 4 |
15 files changed, 127 insertions, 30 deletions
diff --git a/sysdeps/unix/common/.cvsignore b/sysdeps/unix/common/.cvsignore deleted file mode 100644 index 1f69fd919a..0000000000 --- a/sysdeps/unix/common/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*.gz *.Z *.tar *.tgz -=* -TODO COPYING* AUTHORS copyr-* copying.* -glibc-* diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 170c042dd1..cee5d29255 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -11,6 +11,10 @@ ifeq ($(subdir),malloc) CFLAGS-malloc.c += -DMORECORE_CLEARS=2 endif +ifeq ($(subdir),socket) +sysdep_routines += internal_accept4 +endif + ifeq ($(subdir),misc) sysdep_routines += sysctl clone llseek umount umount2 readahead \ setfsuid setfsgid makedev epoll_pwait signalfd \ diff --git a/sysdeps/unix/sysv/linux/accept4.c b/sysdeps/unix/sysv/linux/accept4.c index 97f7b8ce62..9ef9f479b0 100644 --- a/sysdeps/unix/sysv/linux/accept4.c +++ b/sysdeps/unix/sysv/linux/accept4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 Free Software Foundation, Inc. +/* Copyright (C) 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2008. @@ -23,8 +23,7 @@ #include <sysdep-cancel.h> #include <sys/syscall.h> - -#define __NR_accept4 288 +#include <kernel-features.h> #ifdef __NR_accept4 @@ -43,6 +42,50 @@ accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) return result; } +#elif defined __NR_socketcall +# ifndef __ASSUME_ACCEPT4 +extern int __internal_accept4 (int fd, __SOCKADDR_ARG addr, + socklen_t *addr_len, int flags) + attribute_hidden; + +static int have_accept4; + +int +accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) +{ + if (__builtin_expect (have_accept4 >= 0, 1)) + { + int ret = __internal_accept4 (fd, addr, addr_len, flags); + /* The kernel returns -EINVAL for unknown socket operations. + We need to convert that error to an ENOSYS error. */ + if (__builtin_expect (ret < 0, 0) + && have_accept4 == 0 + && errno == EINVAL) + { + /* Try another call, this time with the FLAGS parameter + cleared and an invalid file descriptor. This call will not + cause any harm and it will return immediately. */ + ret = __internal_accept4 (-1, addr, addr_len, 0); + if (errno == EINVAL) + { + have_accept4 = -1; + __set_errno (ENOSYS); + } + else + { + have_accept4 = 1; + __set_errno (EINVAL); + } + return -1; + } + return ret; + } + __set_errno (ENOSYS); + return -1; +} +# else +/* When __ASSUME_ACCEPT4 accept4 is defined in internal_accept4.S. */ +# endif #else int accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h index 88062e59ad..f23b338a35 100644 --- a/sysdeps/unix/sysv/linux/bits/socket.h +++ b/sysdeps/unix/sysv/linux/bits/socket.h @@ -1,5 +1,5 @@ /* System-specific socket constants and types. Linux version. - Copyright (C) 1991, 1992, 1994-2001, 2004, 2006, 2007, 2008 + Copyright (C) 1991, 1992, 1994-2001, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -108,7 +108,8 @@ enum __socket_type #define PF_RXRPC 33 /* RxRPC sockets. */ #define PF_ISDN 34 /* mISDN sockets. */ #define PF_PHONET 35 /* Phonet sockets. */ -#define PF_MAX 36 /* For now.. */ +#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */ +#define PF_MAX 37 /* For now.. */ /* Address families. */ #define AF_UNSPEC PF_UNSPEC @@ -148,6 +149,7 @@ enum __socket_type #define AF_RXRPC PF_RXRPC #define AF_ISDN PF_ISDN #define AF_PHONET PF_PHONET +#define AF_IEEE802154 PF_IEEE802154 #define AF_MAX PF_MAX /* Socket level values. Others are defined in the appropriate headers. diff --git a/sysdeps/unix/sysv/linux/eventfd.c b/sysdeps/unix/sysv/linux/eventfd.c index 4cd557983e..7f69ecdb8c 100644 --- a/sysdeps/unix/sysv/linux/eventfd.c +++ b/sysdeps/unix/sysv/linux/eventfd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2007, 2008, 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 @@ -19,14 +19,21 @@ #include <errno.h> #include <sys/eventfd.h> #include <sysdep.h> +#include <kernel-features.h> int eventfd (int count, int flags) { #ifdef __NR_eventfd2 - return INLINE_SYSCALL (eventfd2, 2, count, flags); -#else + int res = INLINE_SYSCALL (eventfd2, 2, count, flags); +# ifndef __ASSUME_EVENTFD2 + if (res != -1 || errno != ENOSYS) +# endif + return res; +#endif + +#ifndef __ASSUME_EVENTFD2 /* The old system call has no flag parameter which is bad. So we have to wait until we have to support to pass additional values to the kernel (sys_indirect) before implementing setting flags like @@ -43,5 +50,7 @@ eventfd (int count, int flags) __set_errno (ENOSYS); return -1; # endif +#elif !defined __NR_eventfd2 +# error "__ASSUME_EVENTFD2 defined but not __NR_eventfd2" #endif } diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c index b894b8b631..c858f89c8b 100644 --- a/sysdeps/unix/sysv/linux/grantpt.c +++ b/sysdeps/unix/sysv/linux/grantpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2001, 2002, 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 @@ -70,9 +70,16 @@ grantpt (int fd) return -1; /* If the slave pseudo terminal lives on a `devpts' filesystem, the - ownership and access permission are already set. */ + ownership is already set and the access permission might already + be set. */ if (fsbuf.f_type == DEVPTS_SUPER_MAGIC || fsbuf.f_type == DEVFS_SUPER_MAGIC) - return 0; + { + struct stat64 st; + + if (fstat (fd, &st) == 0 + && (st.st_mode & ACCESSPERMS) == (S_IRUSR|S_IWUSR|S_IWGRP)) + return 0; + } return __unix_grantpt (fd); } diff --git a/sysdeps/unix/sysv/linux/i386/accept4.S b/sysdeps/unix/sysv/linux/i386/accept4.S index 087ccc456f..1d05eff7f7 100644 --- a/sysdeps/unix/sysv/linux/i386/accept4.S +++ b/sysdeps/unix/sysv/linux/i386/accept4.S @@ -24,10 +24,6 @@ #define EINVAL 22 #define ENOSYS 38 -#ifndef SOCKOP_accept4 -# define SOCKOP_accept4 18 -#endif - #ifdef __ASSUME_ACCEPT4 # define errlabel SYSCALL_ERROR_LABEL #else diff --git a/sysdeps/unix/sysv/linux/i386/internal_accept4.S b/sysdeps/unix/sysv/linux/i386/internal_accept4.S new file mode 100644 index 0000000000..c3f1630494 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/internal_accept4.S @@ -0,0 +1 @@ +/* Not needed, accept4.S has everything. */ diff --git a/sysdeps/unix/sysv/linux/internal_accept4.S b/sysdeps/unix/sysv/linux/internal_accept4.S new file mode 100644 index 0000000000..ffc553624c --- /dev/null +++ b/sysdeps/unix/sysv/linux/internal_accept4.S @@ -0,0 +1,14 @@ +#include <kernel-features.h> +#include <sys/syscall.h> +#if !defined __NR_accept4 && defined __NR_socketcall +# define socket accept4 +# ifdef __ASSUME_ACCEPT4 +# define __socket accept4 +# else +# define __socket __internal_accept4 +# endif +# define NARGS 4 +# define NEED_CANCELLATION +# define NO_WEAK_ALIAS +# include <socket.S> +#endif diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 473360a13c..ff065effb5 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -516,12 +516,14 @@ # define __ASSUME_SOCK_CLOEXEC 1 # define __ASSUME_IN_NONBLOCK 1 # define __ASSUME_PIPE2 1 +# define __ASSUME_EVENTFD2 1 +# define __ASSUME_SIGNALFD4 1 #endif /* Support for the accept4 syscall was added in 2.6.28. */ #if __LINUX_KERNEL_VERSION >= 0x02061c \ && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \ - || defined __ia64__ || defined __sparc__ || defined __s390__) + || defined __sparc__ || defined __s390__) # define __ASSUME_ACCEPT4 1 #endif diff --git a/sysdeps/unix/sysv/linux/net/if_arp.h b/sysdeps/unix/sysv/linux/net/if_arp.h index 9608652ee4..97cb61f62b 100644 --- a/sysdeps/unix/sysv/linux/net/if_arp.h +++ b/sysdeps/unix/sysv/linux/net/if_arp.h @@ -1,5 +1,5 @@ /* Definitions for Address Resolution Protocol. - Copyright (C) 1997,1999,2001,2006 Free Software Foundation, Inc. + Copyright (C) 1997,1999,2001,2006,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -128,6 +128,8 @@ struct arphdr #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */ #define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header. */ #define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header. */ +#define ARPHRD_IEEE802154 804 /* IEEE 802.15.4 header. */ +#define ARPHRD_IEEE802154_PHY 805 /* IEEE 802.15.4 PHY header. */ #define ARPHRD_VOID 0xFFFF /* Void type, nothing is known. */ #define ARPHRD_NONE 0xFFFE /* Zero header length. */ diff --git a/sysdeps/unix/sysv/linux/signalfd.c b/sysdeps/unix/sysv/linux/signalfd.c index 9898f29231..c2d974a45d 100644 --- a/sysdeps/unix/sysv/linux/signalfd.c +++ b/sysdeps/unix/sysv/linux/signalfd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2007, 2008, 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 @@ -20,14 +20,21 @@ #include <signal.h> #include <sys/signalfd.h> #include <sysdep.h> +#include <kernel-features.h> int signalfd (int fd, const sigset_t *mask, int flags) { #ifdef __NR_signalfd4 - return INLINE_SYSCALL (signalfd4, 4, fd, mask, _NSIG / 8, flags); -#else + int res = INLINE_SYSCALL (signalfd4, 4, fd, mask, _NSIG / 8, flags); +# ifndef __ASSUME_SIGNALFD4 + if (res != -1 || errno != ENOSYS) +# endif + return res; +#endif + +#ifndef __ASSUME_SIGNALFD4 /* The old system call has no flag parameter which is bad. So we have to wait until we have to support to pass additional values to the kernel (sys_indirect) before implementing setting flags like @@ -44,5 +51,7 @@ signalfd (int fd, const sigset_t *mask, int flags) __set_errno (ENOSYS); return -1; # endif +#elif !defined __NR_signalfd4 +# error "__ASSUME_SIGNALFD4 defined but not __NR_signalfd4" #endif } diff --git a/sysdeps/unix/sysv/linux/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h index 24ec9ee2ac..adf01b6e10 100644 --- a/sysdeps/unix/sysv/linux/socketcall.h +++ b/sysdeps/unix/sysv/linux/socketcall.h @@ -1,5 +1,5 @@ /* ID for functions called via socketcall system call. - Copyright (C) 1995, 1996, 2008 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2008, 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 @@ -43,6 +43,6 @@ #define SOCKOP_getsockopt 15 #define SOCKOP_sendmsg 16 #define SOCKOP_recvmsg 17 -#define SOCKOP_paccept 18 +#define SOCKOP_accept4 18 #endif /* sys/socketcall.h */ diff --git a/sysdeps/unix/sysv/linux/sparc/bits/socket.h b/sysdeps/unix/sysv/linux/sparc/bits/socket.h index d43a3cdf79..a148072095 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/socket.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/socket.h @@ -1,5 +1,5 @@ /* System-specific socket constants and types. Linux/SPARC version. - Copyright (C) 1991, 1992, 1994-2001, 2004, 2006, 2007, 2008 + Copyright (C) 1991, 1992, 1994-2001, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -94,15 +94,21 @@ enum __socket_type #define PF_ASH 18 /* Ash. */ #define PF_ECONET 19 /* Acorn Econet. */ #define PF_ATMSVC 20 /* ATM SVCs. */ +#define PF_RDS 21 /* RDS sockets. */ #define PF_SNA 22 /* Linux SNA Project */ #define PF_IRDA 23 /* IRDA sockets. */ #define PF_PPPOX 24 /* PPPoX sockets. */ #define PF_WANPIPE 25 /* Wanpipe API sockets. */ +#define PF_LLC 26 /* Linux LLC. */ +#define PF_CAN 29 /* Controller Area Network. */ +#define PF_TIPC 30 /* TIPC sockets. */ #define PF_BLUETOOTH 31 /* Bluetooth sockets. */ #define PF_IUCV 32 /* IUCV sockets. */ #define PF_RXRPC 33 /* RxRPC sockets. */ #define PF_ISDN 34 /* mISDN sockets. */ -#define PF_MAX 35 /* For now.. */ +#define PF_PHONET 35 /* Phonet sockets. */ +#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */ +#define PF_MAX 37 /* For now.. */ /* Address families. */ #define AF_UNSPEC PF_UNSPEC @@ -129,14 +135,20 @@ enum __socket_type #define AF_ASH PF_ASH #define AF_ECONET PF_ECONET #define AF_ATMSVC PF_ATMSVC +#define AF_RDS PF_RDS #define AF_SNA PF_SNA #define AF_IRDA PF_IRDA #define AF_PPPOX PF_PPPOX #define AF_WANPIPE PF_WANPIPE +#define AF_LLC PF_LLC +#define AF_CAN PF_CAN +#define AF_TIPC PF_TIPC #define AF_BLUETOOTH PF_BLUETOOTH #define AF_IUCV PF_IUCV #define AF_RXRPC PF_RXRPC #define AF_ISDN PF_ISDN +#define AF_PHONET PF_PHONET +#define AF_IEEE802154 PF_IEEE802154 #define AF_MAX PF_MAX /* Socket level values. Others are defined in the appropriate headers. diff --git a/sysdeps/unix/sysv/linux/sys/epoll.h b/sysdeps/unix/sysv/linux/sys/epoll.h index 12de0bcfe2..ca1d3d0459 100644 --- a/sysdeps/unix/sysv/linux/sys/epoll.h +++ b/sysdeps/unix/sysv/linux/sys/epoll.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2002-2006, 2007, 2008, 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 @@ -31,7 +31,7 @@ typedef __sigset_t sigset_t; #endif -/* Flags to be passed to epoll_create2. */ +/* Flags to be passed to epoll_create1. */ enum { EPOLL_CLOEXEC = 02000000, |