diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-04-24 08:55:46 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2006-04-24 08:55:46 +0000 |
commit | d0145e03799e484f3a53d79de3b3f34162ee9d3c (patch) | |
tree | d8c51a0952204f9015de0db3319d4c820e8646e0 /sysdeps/unix | |
parent | f5ce81c94cc27035f44d37bffa7f7e08dbce7631 (diff) | |
download | glibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.tar glibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.tar.gz glibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.tar.bz2 glibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.zip |
Updated to fedora-glibc-20060424T0820
Diffstat (limited to 'sysdeps/unix')
26 files changed, 546 insertions, 62 deletions
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index fed28f2db0..ad7a8701fd 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -123,6 +123,9 @@ libc { #errlist-compat 132 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } + GLIBC_2.5 { + splice; sync_file_range; tee; + } GLIBC_PRIVATE { # functions used in other libraries __syscall_rt_sigqueueinfo; diff --git a/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h index c4a9b77e2e..6898fe8743 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995-1999, 2000, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-2000, 2004, 2005, 2006 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 @@ -173,10 +173,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h index 77e9b83c92..356a2ece74 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 Free Software Foundation, Inc. + Copyright (C) 1991,1992,1994-2001,2004,2006 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 @@ -221,7 +221,10 @@ struct msghdr size_t msg_iovlen; /* Number of elements in the vector. */ void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ - size_t msg_controllen; /* Ancillary data buffer length. */ + size_t msg_controllen; /* Ancillary data buffer length. + !! The type should be socklen_t but the + definition of the kernel is incompatible + with this. */ int msg_flags; /* Flags on received message. */ }; @@ -230,7 +233,10 @@ struct msghdr struct cmsghdr { size_t cmsg_len; /* Length of data in cmsg_data plus length - of cmsghdr structure. */ + of cmsghdr structure. + !! The type should be socklen_t but the + definition of the kernel is incompatible + with this. */ int cmsg_level; /* Originating protocol. */ int cmsg_type; /* Protocol specific type. */ #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index ae6f71d89c..f186182cf6 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -29,11 +29,18 @@ #include <linux/netlink.h> #include <linux/rtnetlink.h> +#include <not-cancel.h> #include <kernel-features.h> +#ifndef IFA_F_TEMPORARY +# define IFA_F_TEMPORARY IFA_F_SECONDARY +#endif + + static int -make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6) +make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, + struct in6addrinfo **in6ai, size_t *in6ailen) { struct { @@ -63,6 +70,12 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6) bool done = false; char buf[4096]; struct iovec iov = { buf, sizeof (buf) }; + struct in6ailist + { + struct in6addrinfo info; + struct in6ailist *next; + } *in6ailist = NULL; + size_t in6ailistlen = 0; do { @@ -101,6 +114,42 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6) break; case AF_INET6: *seen_ipv6 = true; + + if (ifam->ifa_flags & (IFA_F_DEPRECATED | IFA_F_TEMPORARY)) + { + struct rtattr *rta = IFA_RTA (ifam); + size_t len = (nlmh->nlmsg_len + - NLMSG_LENGTH (sizeof (*ifam))); + void *local = NULL; + void *address = NULL; + while (RTA_OK (rta, len)) + { + switch (rta->rta_type) + { + case IFA_LOCAL: + local = RTA_DATA (rta); + break; + + case IFA_ADDRESS: + address = RTA_DATA (rta); + break; + } + + rta = RTA_NEXT (rta, len); + } + + struct in6ailist *newp = alloca (sizeof (*newp)); + newp->info.flags = (((ifam->ifa_flags & IFA_F_DEPRECATED) + ? in6ai_deprecated : 0) + | ((ifam->ifa_flags + & IFA_F_TEMPORARY) + ? in6ai_temporary : 0)); + memcpy (newp->info.addr, address ?: local, + sizeof (newp->info.addr)); + newp->next = in6ailist; + in6ailist = newp; + ++in6ailistlen; + } break; default: /* Ignore. */ @@ -110,12 +159,27 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6) else if (nlmh->nlmsg_type == NLMSG_DONE) /* We found the end, leave the loop. */ done = true; - else ; } } while (! done); - __close (fd); + close_not_cancel_no_status (fd); + + if (in6ailist != NULL) + { + *in6ai = malloc (in6ailistlen * sizeof (**in6ai)); + if (*in6ai == NULL) + return -1; + + *in6ailen = in6ailistlen; + + do + { + (*in6ai)[--in6ailistlen] = in6ailist->info; + in6ailist = in6ailist->next; + } + while (in6ailist != NULL); + } return 0; } @@ -133,8 +197,12 @@ extern int __no_netlink_support attribute_hidden; void attribute_hidden -__check_pf (bool *seen_ipv4, bool *seen_ipv6) +__check_pf (bool *seen_ipv4, bool *seen_ipv6, + struct in6addrinfo **in6ai, size_t *in6ailen) { + *in6ai = NULL; + *in6ailen = 0; + if (! __no_netlink_support) { int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); @@ -148,7 +216,8 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6) if (fd >= 0 && __bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0 && __getsockname (fd, (struct sockaddr *) &nladdr, &addr_len) == 0 - && make_request (fd, nladdr.nl_pid, seen_ipv4, seen_ipv6) == 0) + && make_request (fd, nladdr.nl_pid, seen_ipv4, seen_ipv6, + in6ai, in6ailen) == 0) /* It worked. */ return; @@ -178,9 +247,6 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6) return; } - *seen_ipv4 = false; - *seen_ipv6 = false; - struct ifaddrs *runp; for (runp = ifa; runp != NULL; runp = runp->ifa_next) if (runp->ifa_addr->sa_family == PF_INET) diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c index 1a308ca38f..911d85f43d 100644 --- a/sysdeps/unix/sysv/linux/getcwd.c +++ b/sysdeps/unix/sysv/linux/getcwd.c @@ -87,7 +87,7 @@ __getcwd (char *buf, size_t size) return NULL; } - alloc_size = PATH_MAX; + alloc_size = MAX (PATH_MAX, __getpagesize ()); } if (buf == NULL) diff --git a/sysdeps/unix/sysv/linux/getsourcefilter.c b/sysdeps/unix/sysv/linux/getsourcefilter.c index fdcf8d6130..a6f89a3cc9 100644 --- a/sysdeps/unix/sysv/linux/getsourcefilter.c +++ b/sysdeps/unix/sysv/linux/getsourcefilter.c @@ -1,5 +1,5 @@ /* Get source filter. Linux version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. @@ -112,23 +112,27 @@ getsourcefilter (int s, uint32_t interface, const struct sockaddr *group, gf->gf_numsrc = *numsrc; /* We need to provide the appropriate socket level value. */ + int result; int sol = __get_sol (group->sa_family, grouplen); if (sol == -1) { __set_errno (EINVAL); - return -1; + result = -1; } - - int result = __getsockopt (s, sol, MCAST_MSFILTER, gf, &needed); - - /* If successful, copy the results to the places the caller wants - them in. */ - if (result == 0) + else { - *fmode = gf->gf_fmode; - memcpy (slist, gf->gf_slist, - MIN (*numsrc, gf->gf_numsrc) * sizeof (struct sockaddr_storage)); - *numsrc = gf->gf_numsrc; + result = __getsockopt (s, sol, MCAST_MSFILTER, gf, &needed); + + /* If successful, copy the results to the places the caller wants + them in. */ + if (result == 0) + { + *fmode = gf->gf_fmode; + memcpy (slist, gf->gf_slist, + MIN (*numsrc, gf->gf_numsrc) + * sizeof (struct sockaddr_storage)); + *numsrc = gf->gf_numsrc; + } } if (! use_alloca) diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 9065825b98..a375888106 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 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -180,10 +180,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/i386/sync_file_range.S b/sysdeps/unix/sysv/linux/i386/sync_file_range.S new file mode 100644 index 0000000000..f39e8a00d7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/sync_file_range.S @@ -0,0 +1,72 @@ +/* Selective file content synch'ing. + Copyright (C) 2006 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> +#define _ERRNO_H 1 +#include <bits/errno.h> + + + .text +ENTRY (sync_file_range) +#ifdef __NR_sync_file_range + pushl %ebx + cfi_adjust_cfa_offset (4) + pushl %esi + cfi_adjust_cfa_offset (4) + pushl %edi + cfi_adjust_cfa_offset (4) + pushl %ebp + cfi_adjust_cfa_offset (4) + + movl 20(%esp), %ebx + cfi_rel_offset (ebx, 12) + movl 24(%esp), %ecx + movl 28(%esp), %edx + movl 32(%esp), %esi + cfi_rel_offset (esi, 8) + movl 36(%esp), %edi + cfi_rel_offset (edi, 4) + movl 40(%esp), %ebp + cfi_rel_offset (ebp, 0) + + movl $SYS_ify(sync_file_range), %eax + ENTER_KERNEL + + popl %ebp + cfi_adjust_cfa_offset (-4) + cfi_restore (ebp) + popl %edi + cfi_adjust_cfa_offset (-4) + cfi_restore (edi) + popl %esi + cfi_adjust_cfa_offset (-4) + cfi_restore (esi) + popl %ebx + cfi_adjust_cfa_offset (-4) + cfi_restore (ebx) + + cmpl $-4095, %eax + jae SYSCALL_ERROR_LABEL +L(pseudo_end): + ret +#else + movl $-ENOSYS, %eax + jmp SYSCALL_ERROR_LABEL +#endif +PSEUDO_END (sync_file_range) diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index cb5767955c..90423d8434 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992,1993,1995,1996,1997,1998,1999,2000,2002,2003,2004,2005 +/* Copyright (C) 1992,1993,1995-2000,2002-2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995. @@ -447,7 +447,7 @@ asm (".L__X'%ebx = 1\n\t" #define LOADARGS_0 #ifdef __PIC__ -# if defined I386_USE_SYSENTER +# if defined I386_USE_SYSENTER && defined SHARED # define LOADARGS_1 \ "bpushl .L__X'%k3, %k3\n\t" # define LOADARGS_5 \ diff --git a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index d330954d48..63a771ddb9 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/IA64. - Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2004, 2006 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 @@ -174,10 +174,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 37d25b1a5c..139e3d5a72 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -85,6 +85,12 @@ # define __ASSUME_SENDFILE 1 #endif +/* Only very old kernels had no real symlinks for terminal descriptors + in /proc/self/fd. */ +#if __LINUX_KERNEL_VERSION >= 131584 +# define __ASSUME_PROC_SELF_FD_SYMLINK 1 +#endif + /* On x86 another `getrlimit' syscall was added in 2.3.25. */ #if __LINUX_KERNEL_VERSION >= 131865 && defined __i386__ # define __ASSUME_NEW_GETRLIMIT_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index 19649c01c7..2219271a1b 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/PowerPC. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -180,10 +180,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S index f4c92ad7c7..37b777799c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S @@ -84,6 +84,10 @@ ENTRY (BP_SYM (__clone)) mr r6,r8 mr r7,r9 + /* End FDE now, because in the child the unwind info will be + wrong. */ + cfi_endproc + /* Do the call. */ DO_CALL(SYS_ify(clone)) @@ -138,6 +142,8 @@ L(parent): L(badargs): li r3,EINVAL b __syscall_error@local + + cfi_startproc END (BP_SYM (__clone)) weak_alias (BP_SYM (__clone), BP_SYM (clone)) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S index 366206d286..f1a55e64db 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S @@ -81,6 +81,10 @@ ENTRY (BP_SYM (__clone)) mr r6,r8 mr r7,r9 + /* End FDE now, because in the child the unwind info will be + wrong. */ + cfi_endproc + /* Do the call. */ DO_CALL(SYS_ify(clone)) @@ -132,6 +136,8 @@ L(parent): L(badargs): li r3,EINVAL b JUMPTARGET(__syscall_error) + + cfi_startproc END (BP_SYM (__clone)) weak_alias (BP_SYM (__clone), BP_SYM (clone)) diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h b/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h index d2d5972411..577689f18d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h +++ b/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h @@ -35,7 +35,7 @@ __BEGIN_DECLS /* These definitions are normally provided by ucontext.h via asm/sigcontext.h, asm/ptrace.h, and asm/elf.h. Otherwise we define them here. */ -#ifndef __PPC64_ELF_H +#if !defined __PPC64_ELF_H && !defined _ASM_POWERPC_ELF_H #define ELF_NGREG 48 /* includes nip, msr, lr, etc. */ #define ELF_NFPREG 33 /* includes fpscr */ #if __WORDSIZE == 32 diff --git a/sysdeps/unix/sysv/linux/readlinkat.c b/sysdeps/unix/sysv/linux/readlinkat.c index c2f21ee4ca..9b4a730c0e 100644 --- a/sysdeps/unix/sysv/linux/readlinkat.c +++ b/sysdeps/unix/sysv/linux/readlinkat.c @@ -29,7 +29,7 @@ /* Read the contents of the symbolic link PATH relative to FD into no more than LEN bytes of BUF. */ -int +ssize_t readlinkat (fd, path, buf, len) int fd; const char *path; diff --git a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index 8c47077580..ad3ef420a1 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2004, 2006 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 @@ -199,10 +199,41 @@ struct flock64 # endif #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/setsourcefilter.c b/sysdeps/unix/sysv/linux/setsourcefilter.c index f5c4d9786f..dc223de844 100644 --- a/sysdeps/unix/sysv/linux/setsourcefilter.c +++ b/sysdeps/unix/sysv/linux/setsourcefilter.c @@ -1,5 +1,5 @@ /* Set source filter. Linux version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. @@ -57,14 +57,15 @@ setsourcefilter (int s, uint32_t interface, const struct sockaddr *group, memcpy (gf->gf_slist, slist, numsrc * sizeof (struct sockaddr_storage)); /* We need to provide the appropriate socket level value. */ + int result; int sol = __get_sol (group->sa_family, grouplen); if (sol == -1) { __set_errno (EINVAL); - return -1; + result = -1; } - - int result = __setsockopt (s, sol, MCAST_MSFILTER, gf, needed); + else + result = __setsockopt (s, sol, MCAST_MSFILTER, gf, needed); if (! use_alloca) { diff --git a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index 9065825b98..a375888106 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -180,10 +180,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index 5dc8bf32f0..b3788f0daf 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/SPARC. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -199,10 +199,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS diff --git a/sysdeps/unix/sysv/linux/sync_file_range.c b/sysdeps/unix/sysv/linux/sync_file_range.c new file mode 100644 index 0000000000..aabe192341 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sync_file_range.c @@ -0,0 +1,46 @@ +/* Selective file content synch'ing. + Copyright (C) 2006 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <sys/types.h> + +#include <sysdep.h> +#include <sys/syscall.h> + + +#ifdef __NR_sync_file_range +int +sync_file_range (int fd, __off64_t from, __off64_t to, int flags) +{ + return INLINE_SYSCALL (sync_file_range, 6, fd, (off_t) (from >> 32), + (off_t) (from & 0xffffffff), (off_t) (to >> 32), + (off_t) (to & 0xffffffff), flags); +} +#else +int +sync_file_range (int fd, __off64_t from, __off64_t to, int flags) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sync_file_range) + +# include <stub-tag.h> +#endif diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 053d7e0ccf..6bfccd26aa 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -70,9 +70,11 @@ setfsgid EXTRA setfsgid i:i setfsgid setfsuid EXTRA setfsuid i:i setfsuid setpgid - setpgid i:ii __setpgid setpgid sigaltstack - sigaltstack i:PP __sigaltstack sigaltstack +splice EXTRA splice i:iiii splice sysinfo EXTRA sysinfo i:p sysinfo swapon - swapon i:si __swapon swapon swapoff - swapoff i:s __swapoff swapoff +tee EXTRA tee i:iiii tee unshare EXTRA unshare i:i unshare uselib EXTRA uselib i:s uselib wait4 - wait4 i:iWiP __wait4 wait4 diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 68d24f195e..aed0fd8e0a 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,1996-2001,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,1996-2002,2006 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 @@ -27,6 +27,7 @@ #include <stdlib.h> #include <stdio-common/_itoa.h> +#include <kernel-features.h> #if 0 /* Is this used anywhere? It is not exported. */ @@ -41,7 +42,7 @@ static char *getttyname (const char *dev, dev_t mydev, libc_freeres_ptr (static char *getttyname_name); static char * -internal_function +internal_function attribute_compat_text_section getttyname (const char *dev, dev_t mydev, ino64_t myino, int save, int *dostat) { static size_t namelen; @@ -117,10 +118,12 @@ ttyname (int fd) int dostat = 0; char *name; int save = errno; - int len; - if (!__isatty (fd)) - return NULL; + if (__builtin_expect (!__isatty (fd), 0)) + { + __set_errno (ENOTTY); + return NULL; + } /* We try using the /proc filesystem. */ *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; @@ -136,10 +139,19 @@ ttyname (int fd) } } - len = __readlink (procname, ttyname_buf, buflen); - if (len != -1 - /* This is for Linux 2.0. */ - && ttyname_buf[0] != '[') + ssize_t len = __readlink (procname, ttyname_buf, buflen); + if (__builtin_expect (len == -1 && errno == ENOENT, 0)) + { + __set_errno (EBADF); + return NULL; + } + + if (__builtin_expect (len != -1 +#ifndef __ASSUME_PROC_SELF_FD_SYMLINK + /* This is for Linux 2.0. */ + && ttyname_buf[0] != '[' +#endif + , 1)) { if ((size_t) len >= buflen) return NULL; diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c index eee4d862b2..bd415f167b 100644 --- a/sysdeps/unix/sysv/linux/ttyname_r.c +++ b/sysdeps/unix/sysv/linux/ttyname_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,1995-2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,1995-2001,2003,2006 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 @@ -27,13 +27,14 @@ #include <stdlib.h> #include <stdio-common/_itoa.h> +#include <kernel-features.h> static int getttyname_r (char *buf, size_t buflen, dev_t mydev, ino64_t myino, int save, int *dostat) internal_function; static int -internal_function +internal_function attribute_compat_text_section getttyname_r (char *buf, size_t buflen, dev_t mydev, ino64_t myino, int save, int *dostat) { @@ -99,7 +100,6 @@ __ttyname_r (int fd, char *buf, size_t buflen) struct stat64 st, st1; int dostat = 0; int save = errno; - int ret; /* Test for the absolute minimal size. This makes life easier inside the loop. */ @@ -115,29 +115,34 @@ __ttyname_r (int fd, char *buf, size_t buflen) return ERANGE; } + if (__builtin_expect (!__isatty (fd), 0)) + { + __set_errno (ENOTTY); + return ENOTTY; + } + /* We try using the /proc filesystem. */ *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; - ret = __readlink (procname, buf, buflen - 1); - if (ret == -1 && errno == ENOENT) + ssize_t ret = __readlink (procname, buf, buflen - 1); + if (__builtin_expect (ret == -1 && errno == ENOENT, 0)) { __set_errno (EBADF); return EBADF; } - if (!__isatty (fd)) - { - __set_errno (ENOTTY); - return ENOTTY; - } - - if (ret == -1 && errno == ENAMETOOLONG) + if (__builtin_expect (ret == -1 && errno == ENAMETOOLONG, 0)) { __set_errno (ERANGE); return ERANGE; } - if (ret != -1 && buf[0] != '[') + if (__builtin_expect (ret != -1 +#ifndef __ASSUME_PROC_SELF_FD_SYMLINK + /* This is for Linux 2.0. */ + && buf[0] != '[' +#endif + , 1)) { buf[ret] = '\0'; return 0; diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list index 58904fc4d4..d377db9687 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list @@ -14,3 +14,4 @@ getrlimit - getrlimit i:ip __getrlimit getrlimit getrlimit64 setrlimit - setrlimit i:ip __setrlimit setrlimit setrlimit64 readahead - readahead i:iii __readahead readahead sendfile - sendfile i:iipi sendfile sendfile64 +sync_file_range - sync_file_range i:iiii sync_file_range diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index 9198c70bd4..2351737f7c 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/x86-64. - Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2004, 2006 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 @@ -194,10 +194,41 @@ struct flock64 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif + +#ifdef __USE_GNU +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ +#endif + __BEGIN_DECLS +#ifdef __USE_GNU + /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; + +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +#endif + __END_DECLS |