diff options
Diffstat (limited to 'sysdeps/unix')
69 files changed, 615 insertions, 163 deletions
diff --git a/sysdeps/unix/mkfifoat.c b/sysdeps/unix/mkfifoat.c new file mode 100644 index 0000000000..5c4da2a982 --- /dev/null +++ b/sysdeps/unix/mkfifoat.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2005 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 <sys/stat.h> + + +/* Create a new FIFO with permission bits MODE. But interpret + relative PATH names relative to the directory associated with FD. */ +int +mkfifoat (fd, file, mode) + int fd; + const char *file; + mode_t mode; +{ + dev_t dev = 0; + return __xmknodat (_MKNOD_VER, fd, file, mode | S_IFIFO, &dev); +} diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c index 98fb4ca5c8..6aa738fb69 100644 --- a/sysdeps/unix/opendir.c +++ b/sysdeps/unix/opendir.c @@ -139,7 +139,7 @@ weak_alias (__opendir, opendir) DIR * internal_function -__alloc_dir (int fd, bool close_fd, struct stat64 *statp) +__alloc_dir (int fd, bool close_fd, const struct stat64 *statp) { if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0) goto lose; diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index b2bbbc0b28..812cd97c80 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -107,11 +107,6 @@ ifeq ($(subdir),termios) sysdep_headers += termio.h endif -ifeq ($(subdir),stdio-common) -# Just disable the auto generation in sysdeps/generic -inhibit-siglist := yes -endif - ifeq ($(subdir),posix) sysdep_headers += bits/initspin.h diff --git a/sysdeps/unix/sysv/linux/aio_sigqueue.c b/sysdeps/unix/sysv/linux/aio_sigqueue.c index 44ff22ea7d..a6dbfb4eb1 100644 --- a/sysdeps/unix/sysv/linux/aio_sigqueue.c +++ b/sysdeps/unix/sysv/linux/aio_sigqueue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999, 2000, 2003, 2005 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 @@ -52,5 +52,5 @@ __aio_sigqueue (sig, val, caller_pid) sig, __ptrvalue (&info)); } #else -# include <sysdeps/generic/aio_sigqueue.c> +# include <rt/aio_sigqueue.c> #endif diff --git a/sysdeps/unix/sysv/linux/alpha/bits/mman.h b/sysdeps/unix/sysv/linux/alpha/bits/mman.h index bb41887479..59574266a4 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/mman.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/mman.h @@ -86,6 +86,7 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif /* Advice to `madvise'. */ diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat.c b/sysdeps/unix/sysv/linux/alpha/fxstatat.c index 65b7ad97a3..127f7f3c57 100644 --- a/sysdeps/unix/sysv/linux/alpha/fxstatat.c +++ b/sysdeps/unix/sysv/linux/alpha/fxstatat.c @@ -67,7 +67,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64) { - if (flags & AT_SYMLINK_NOFOLLOW) + if (flag & AT_SYMLINK_NOFOLLOW) result = INTERNAL_SYSCALL (lstat64, err, 2, file, st); else result = INTERNAL_SYSCALL (stat64, err, 2, file, st); @@ -94,7 +94,4 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) return -1; } -hidden_def (__xstat) -weak_alias (__xstat, _xstat); -strong_alias (__xstat, __xstat64); -hidden_ver (__xstat, __xstat64) +strong_alias (__fxstatat, __fxstatat64); diff --git a/sysdeps/unix/sysv/linux/alpha/glob.c b/sysdeps/unix/sysv/linux/alpha/glob.c index a51020d51f..84573899d6 100644 --- a/sysdeps/unix/sysv/linux/alpha/glob.c +++ b/sysdeps/unix/sysv/linux/alpha/glob.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2002, 2005 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 @@ -35,7 +35,7 @@ extern int __new_glob (const char *__pattern, int __flags, glob_t *__pglob); extern void __new_globfree (glob_t *__pglob); -#include <sysdeps/generic/glob.c> +#include <posix/glob.c> #undef glob #undef globfree diff --git a/sysdeps/unix/sysv/linux/alpha/sigaction.c b/sysdeps/unix/sysv/linux/alpha/sigaction.c index 21a2063c30..26b081d9a3 100644 --- a/sysdeps/unix/sysv/linux/alpha/sigaction.c +++ b/sysdeps/unix/sysv/linux/alpha/sigaction.c @@ -17,6 +17,8 @@ 02111-1307 USA. */ #include <sysdep.h> +#include <sys/cdefs.h> +#include <stddef.h> /* * In order to get the hidden arguments for rt_sigaction set up diff --git a/sysdeps/unix/sysv/linux/alpha/wordexp.c b/sysdeps/unix/sysv/linux/alpha/wordexp.c index 1921a03388..c2972e40c2 100644 --- a/sysdeps/unix/sysv/linux/alpha/wordexp.c +++ b/sysdeps/unix/sysv/linux/alpha/wordexp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2004, 2005 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 @@ -22,7 +22,7 @@ #define wordexp(words, pwordexp, flags) \ __new_wordexp (words, pwordexp, flags) -#include <sysdeps/generic/wordexp.c> +#include <posix/wordexp.c> versioned_symbol (libc, __new_wordexp, wordexp, GLIBC_2_2_2); diff --git a/sysdeps/unix/sysv/linux/dl-sbrk.c b/sysdeps/unix/sysv/linux/dl-sbrk.c index 4713a92694..1ce5cb188c 100644 --- a/sysdeps/unix/sysv/linux/dl-sbrk.c +++ b/sysdeps/unix/sysv/linux/dl-sbrk.c @@ -2,4 +2,4 @@ from ld.so. */ extern void *__curbrk attribute_hidden; -#include <sbrk.c> +#include <misc/sbrk.c> diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.c b/sysdeps/unix/sysv/linux/dl-sysdep.c index 79f95df0a2..acc2441051 100644 --- a/sysdeps/unix/sysv/linux/dl-sysdep.c +++ b/sysdeps/unix/sysv/linux/dl-sysdep.c @@ -1,5 +1,5 @@ /* Dynamic linker system dependencies for Linux. - Copyright (C) 1995, 1997, 2001, 2004 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2001, 2004, 2005 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 @@ -53,4 +53,4 @@ frob_brk (void) #endif } -#include <sysdeps/generic/dl-sysdep.c> +#include <elf/dl-sysdep.c> diff --git a/sysdeps/unix/sysv/linux/fchownat.c b/sysdeps/unix/sysv/linux/fchownat.c index f8bc5e3033..10d87e87fc 100644 --- a/sysdeps/unix/sysv/linux/fchownat.c +++ b/sysdeps/unix/sysv/linux/fchownat.c @@ -23,6 +23,8 @@ #include <string.h> #include <unistd.h> #include <sys/types.h> +#include <alloca.h> +#include <sysdep.h> /* Change the owner and group of FILE. */ int diff --git a/sysdeps/unix/sysv/linux/ftruncate64.c b/sysdeps/unix/sysv/linux/ftruncate64.c index 26caee2f46..4c60a1f19a 100644 --- a/sysdeps/unix/sysv/linux/ftruncate64.c +++ b/sysdeps/unix/sysv/linux/ftruncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,1999,2000,2001,2003 Free Software Foundation, Inc. +/* Copyright (C) 1997,1998,1999,2000,2001,2003, 2005 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 @@ -72,5 +72,5 @@ weak_alias (__ftruncate64, ftruncate64) #else /* Use the generic implementation. */ -# include <sysdeps/generic/ftruncate64.c> +# include <posix/ftruncate64.c> #endif diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c index 2360f50d98..31113d5db5 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -20,6 +20,7 @@ #include <fcntl.h> #include <stddef.h> #include <stdio.h> +#include <string.h> #include <sys/stat.h> #include <kernel_stat.h> diff --git a/sysdeps/unix/sysv/linux/gai_sigqueue.c b/sysdeps/unix/sysv/linux/gai_sigqueue.c index 3e67add0d7..0c6654a386 100644 --- a/sysdeps/unix/sysv/linux/gai_sigqueue.c +++ b/sysdeps/unix/sysv/linux/gai_sigqueue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2003, 2005 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 @@ -52,5 +52,5 @@ __gai_sigqueue (sig, val, caller_pid) sig, __ptrvalue (&info)); } #else -# include <sysdeps/generic/gai_sigqueue.c> +# include <resolv/gai_sigqueue.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/getmsg.c b/sysdeps/unix/sysv/linux/i386/getmsg.c index e6ca88d136..c0efd56369 100644 --- a/sysdeps/unix/sysv/linux/i386/getmsg.c +++ b/sysdeps/unix/sysv/linux/i386/getmsg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2003, 2005 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 @@ -34,5 +34,5 @@ getmsg (fildes, ctlptr, dataptr, flagsp) return INLINE_SYSCALL (getpmsg, 5, fildes, ctlptr, dataptr, NULL, flagsp); } #else -# include <sysdeps/generic/getmsg.c> +# include <streams/getmsg.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/getresgid.c b/sysdeps/unix/sysv/linux/i386/getresgid.c index 8028dec3f9..ea3318e7f5 100644 --- a/sysdeps/unix/sysv/linux/i386/getresgid.c +++ b/sysdeps/unix/sysv/linux/i386/getresgid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2002, 2003, 2005 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 @@ -81,5 +81,5 @@ libc_hidden_def (__getresgid) weak_alias (__getresgid, getresgid) #else -# include <sysdeps/generic/getresgid.c> +# include <posix/getresgid.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/getresuid.c b/sysdeps/unix/sysv/linux/i386/getresuid.c index 6b94bbb66c..b2783d075c 100644 --- a/sysdeps/unix/sysv/linux/i386/getresuid.c +++ b/sysdeps/unix/sysv/linux/i386/getresuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2002, 2003, 2005 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 @@ -80,5 +80,5 @@ libc_hidden_def (__getresuid) weak_alias (__getresuid, getresuid) #else -# include <sysdeps/generic/getresuid.c> +# include <posix/getresuid.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/getrlimit64.c b/sysdeps/unix/sysv/linux/i386/getrlimit64.c index d6ab86f3e4..2ff175393c 100644 --- a/sysdeps/unix/sysv/linux/i386/getrlimit64.c +++ b/sysdeps/unix/sysv/linux/i386/getrlimit64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2005 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 @@ -18,7 +18,7 @@ #define getrlimit64 __new_getrlimit64 -#include <sysdeps/generic/getrlimit64.c> +#include <resource/getrlimit64.c> #undef getrlimit64 #include <shlib-compat.h> diff --git a/sysdeps/unix/sysv/linux/i386/glob64.c b/sysdeps/unix/sysv/linux/i386/glob64.c index d3d1212f05..18b7f21ae8 100644 --- a/sysdeps/unix/sysv/linux/i386/glob64.c +++ b/sysdeps/unix/sysv/linux/i386/glob64.c @@ -19,7 +19,7 @@ #define COMPILE_GLOB64 1 -#include <sysdeps/generic/glob.c> +#include <posix/glob.c> #include "shlib-compat.h" @@ -48,7 +48,7 @@ int __old_glob64 (__const char *__pattern, int __flags, #define GLOB_ONLY_P 1 -#include <sysdeps/generic/glob.c> +#include <posix/glob.c> compat_symbol (libc, __old_glob64, glob64, GLIBC_2_1); #endif diff --git a/sysdeps/unix/sysv/linux/i386/lchown.c b/sysdeps/unix/sysv/linux/i386/lchown.c index 1b217a9451..57226277c1 100644 --- a/sysdeps/unix/sysv/linux/i386/lchown.c +++ b/sysdeps/unix/sysv/linux/i386/lchown.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2003, 2005 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,5 +70,5 @@ __lchown (const char *file, uid_t owner, gid_t group) weak_alias (__lchown, lchown) #else -# include <sysdeps/generic/lchown.c> +# include <io/lchown.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/putmsg.c b/sysdeps/unix/sysv/linux/i386/putmsg.c index e7b7a08b55..04fd159b7c 100644 --- a/sysdeps/unix/sysv/linux/i386/putmsg.c +++ b/sysdeps/unix/sysv/linux/i386/putmsg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2003, 2005 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 @@ -34,5 +34,5 @@ putmsg (fildes, ctlptr, dataptr, flags) return INLINE_SYSCALL (putpmsg, 5, fildes, ctlptr, dataptr, -1, flags); } #else -# include <sysdeps/generic/putmsg.c> +# include <streams/putmsg.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/readelflib.c b/sysdeps/unix/sysv/linux/i386/readelflib.c index 6852f2a9a9..a6374e61d2 100644 --- a/sysdeps/unix/sysv/linux/i386/readelflib.c +++ b/sysdeps/unix/sysv/linux/i386/readelflib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>, 1999 and Jakub Jelinek <jakub@redhat.com>, 2000. @@ -73,10 +73,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/i386/setresgid.c b/sysdeps/unix/sysv/linux/i386/setresgid.c index d4093afb0f..fd0dfb342a 100644 --- a/sysdeps/unix/sysv/linux/i386/setresgid.c +++ b/sysdeps/unix/sysv/linux/i386/setresgid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005 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 @@ -80,6 +80,6 @@ weak_alias (__setresgid, setresgid) #else -#include <sysdeps/generic/setresgid.c> +#include <posix/setresgid.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/setresuid.c b/sysdeps/unix/sysv/linux/i386/setresuid.c index 540b954e08..c5651bf85a 100644 --- a/sysdeps/unix/sysv/linux/i386/setresuid.c +++ b/sysdeps/unix/sysv/linux/i386/setresuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005 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 @@ -80,6 +80,6 @@ weak_alias (__setresuid, setresuid) #else -#include <sysdeps/generic/setresuid.c> +#include <posix/setresuid.c> #endif diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 99f9bf1edf..cb5767955c 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -558,4 +558,24 @@ asm (".L__X'%ebx = 1\n\t" #endif /* __ASSEMBLER__ */ + +/* Pointer mangling support. */ +#if defined NOT_IN_libc && defined IS_IN_rtld +/* We cannot use the thread descriptor because in ld.so we use setjmp + earlier than the descriptor is initialized. Using a global variable + is too complicated here since we have no PC-relative addressing mode. */ +#else +# ifdef __ASSEMBLER__ +# define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg +# define PTR_DEMANGLE(reg) PTR_MANGLE (reg) +# else +# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0" \ + : "=r" (var) \ + : "0" (var), \ + "i" (offsetof (tcbhead_t, \ + pointer_guard))) +# define PTR_DEMANGLE(var) PTR_MANGLE (var) +# endif +#endif + #endif /* linux/i386/sysdep.h */ diff --git a/sysdeps/unix/sysv/linux/ia64/readelflib.c b/sysdeps/unix/sysv/linux/ia64/readelflib.c index 9b1a645d34..7a10d23c90 100644 --- a/sysdeps/unix/sysv/linux/ia64/readelflib.c +++ b/sysdeps/unix/sysv/linux/ia64/readelflib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2005 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 @@ -51,10 +51,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 44ac727820..9bbd97e6d2 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -318,6 +318,11 @@ # define __ASSUME_POSIX_TIMERS 1 #endif +/* Beginning with 2.6.12 the clock and timer supports CPU clocks. */ +#if __LINUX_KERNEL_VERSION >= 0x2060c +# define __ASSUME_POSIX_CPU_TIMERS 1 +#endif + /* The late 2.5 kernels saw a lot of new CLONE_* flags. Summarize their availability with one define. The changes were made first for i386 and the have to be done separately for the other archs. diff --git a/sysdeps/unix/sysv/linux/linkat.c b/sysdeps/unix/sysv/linux/linkat.c new file mode 100644 index 0000000000..8ebff74215 --- /dev/null +++ b/sysdeps/unix/sysv/linux/linkat.c @@ -0,0 +1,87 @@ +/* Copyright (C) 2005 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 <string.h> +#include <stdio.h> +#include <sysdep.h> +#include <unistd.h> + + +/* Make a link to FROM named TO but relative paths in TO and FROM are + interpreted relative to FROMFD and TOFD respectively. */ +int +linkat (fromfd, from, tofd, to) + int fromfd; + const char *from; + int tofd; + const char *to; +{ + static const char procfd[] = "/proc/self/fd/%d/%s"; + char *buffrom = NULL; + + if (fromfd != AT_FDCWD && from[0] != '/') + { + size_t filelen = strlen (from); + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buffrom = alloca (buflen); + + __snprintf (buffrom, buflen, procfd, fromfd, from); + from = buffrom; + } + + char *bufto = NULL; + + if (tofd != AT_FDCWD && to[0] != '/') + { + size_t filelen = strlen (to); + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + bufto = alloca (buflen); + + __snprintf (bufto, buflen, procfd, tofd, to); + to = bufto; + } + + INTERNAL_SYSCALL_DECL (err); + + int result = INTERNAL_SYSCALL (link, err, 2, from, to); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + __atfct_seterrno_2 (INTERNAL_SYSCALL_ERRNO (result, err), tofd, bufto, + fromfd, buffrom); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/mips/bits/mman.h b/sysdeps/unix/sysv/linux/mips/bits/mman.h index 154501fba2..92d4b8a340 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/mman.h +++ b/sysdeps/unix/sysv/linux/mips/bits/mman.h @@ -1,5 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/MIPS version. - Copyright (C) 1997, 2000, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1997, 2000, 2003, 2004, 2005 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 @@ -89,4 +89,5 @@ /* Flags for `mremap'. */ #ifdef __USE_GNU # define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 #endif diff --git a/sysdeps/unix/sysv/linux/mips/ftruncate64.c b/sysdeps/unix/sysv/linux/mips/ftruncate64.c index cdb2d56840..11e242570d 100644 --- a/sysdeps/unix/sysv/linux/mips/ftruncate64.c +++ b/sysdeps/unix/sysv/linux/mips/ftruncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -72,5 +72,5 @@ weak_alias (__ftruncate64, ftruncate64) #else /* Use the generic implementation. */ -# include <sysdeps/generic/ftruncate64.c> +# include <misc/ftruncate64.c> #endif diff --git a/sysdeps/unix/sysv/linux/mips/readelflib.c b/sysdeps/unix/sysv/linux/mips/readelflib.c index 73fd43f46f..baa92fe57c 100644 --- a/sysdeps/unix/sysv/linux/mips/readelflib.c +++ b/sysdeps/unix/sysv/linux/mips/readelflib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Alexandre Oliva <aoliva@redhat.com> Based on work ../x86_64/readelflib.c, @@ -62,10 +62,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/mips/truncate64.c b/sysdeps/unix/sysv/linux/mips/truncate64.c index e955f18ea3..d01d25b077 100644 --- a/sysdeps/unix/sysv/linux/mips/truncate64.c +++ b/sysdeps/unix/sysv/linux/mips/truncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003 +/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -72,5 +72,5 @@ truncate64 (const char *path, off64_t length) #else /* Use the generic implementation. */ -# include <sysdeps/generic/truncate64.c> +# include <misc/truncate64.c> #endif diff --git a/sysdeps/unix/sysv/linux/mkdirat.c b/sysdeps/unix/sysv/linux/mkdirat.c new file mode 100644 index 0000000000..367441b05b --- /dev/null +++ b/sysdeps/unix/sysv/linux/mkdirat.c @@ -0,0 +1,66 @@ +/* Copyright (C) 2005 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 <stddef.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sysdep-cancel.h> + + +/* Create a new directory with permission bits MODE. But interpret + relative PATH names relative to the directory associated with FD. */ +int +mkdirat (fd, file, mode) + int fd; + const char *file; + mode_t mode; +{ + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + INTERNAL_SYSCALL_DECL (err); + int res = INTERNAL_SYSCALL (mkdir, err, 2, file, mode); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + { + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (res, err), fd, buf); + res = -1; + } + + return res; +} diff --git a/sysdeps/unix/sysv/linux/mq_close.c b/sysdeps/unix/sysv/linux/mq_close.c index 65522d5adc..008e8eeb95 100644 --- a/sysdeps/unix/sysv/linux/mq_close.c +++ b/sysdeps/unix/sysv/linux/mq_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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,5 +31,5 @@ mq_close (mqd_t mqdes) } #else -# include <sysdeps/generic/mq_close.c> +# include <rt/mq_close.c> #endif diff --git a/sysdeps/unix/sysv/linux/mq_getattr.c b/sysdeps/unix/sysv/linux/mq_getattr.c index a61722e237..d25df7bcfd 100644 --- a/sysdeps/unix/sysv/linux/mq_getattr.c +++ b/sysdeps/unix/sysv/linux/mq_getattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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,5 +31,5 @@ mq_getattr (mqd_t mqdes, struct mq_attr *mqstat) } #else -# include <sysdeps/generic/mq_getattr.c> +# include <rt/mq_getattr.c> #endif diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c index 14db27da70..4eba28a301 100644 --- a/sysdeps/unix/sysv/linux/mq_notify.c +++ b/sysdeps/unix/sysv/linux/mq_notify.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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 @@ -40,5 +40,5 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) } #else -# include <sysdeps/generic/mq_notify.c> +# include <rt/mq_notify.c> #endif diff --git a/sysdeps/unix/sysv/linux/mq_open.c b/sysdeps/unix/sysv/linux/mq_open.c index d8926a73a7..eac6e01238 100644 --- a/sysdeps/unix/sysv/linux/mq_open.c +++ b/sysdeps/unix/sysv/linux/mq_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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 @@ -56,5 +56,5 @@ mq_open (const char *name, int oflag, ...) } #else -# include <sysdeps/generic/mq_open.c> +# include <rt/mq_open.c> #endif diff --git a/sysdeps/unix/sysv/linux/mq_receive.c b/sysdeps/unix/sysv/linux/mq_receive.c index 891663c66a..2186508029 100644 --- a/sysdeps/unix/sysv/linux/mq_receive.c +++ b/sysdeps/unix/sysv/linux/mq_receive.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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 @@ -33,5 +33,5 @@ mq_receive (mqd_t mqdes, char *msg_ptr, size_t msg_len, } #else -# include <sysdeps/generic/mq_receive.c> +# include <rt/mq_receive.c> #endif diff --git a/sysdeps/unix/sysv/linux/mq_send.c b/sysdeps/unix/sysv/linux/mq_send.c index cb9cbc2a69..83b9f8df4a 100644 --- a/sysdeps/unix/sysv/linux/mq_send.c +++ b/sysdeps/unix/sysv/linux/mq_send.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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 @@ -32,5 +32,5 @@ mq_send (mqd_t mqdes, const char *msg_ptr, size_t msg_len, } #else -# include <sysdeps/generic/mq_send.c> +# include <rt/mq_send.c> #endif diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index 8d87ffadf4..bef39a4ae2 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 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 @@ -50,5 +50,5 @@ mq_unlink (const char *name) } #else -# include <sysdeps/generic/mq_unlink.c> +# include <rt/mq_unlink.c> #endif diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/sysdeps/unix/sysv/linux/nscd_setup_thread.c index 7d1bfd8dd1..1589c24ea9 100644 --- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c +++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c @@ -1,22 +1,20 @@ /* Setup of nscd worker threads. Linux verison. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. - 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. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. - The GNU C Library is distributed in the hope that it will be useful, + This program 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. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU 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. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <string.h> #include <unistd.h> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c index 069f94bd9d..cf61b01a54 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c @@ -74,5 +74,5 @@ weak_alias (__ftruncate64, ftruncate64) #else /* Use the generic implementation. */ -# include <sysdeps/generic/ftruncate64.c> +# include <misc/ftruncate64.c> #endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c index ee1b50c04b..af6fa548dd 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c @@ -74,5 +74,5 @@ truncate64 (path, length) #else /* Use the generic implementation. */ -# include <sysdeps/generic/truncate64.c> +# include <misc/truncate64.c> #endif diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c index b4a449cdff..3c6b2daf81 100644 --- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c +++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c @@ -1,5 +1,5 @@ /* Special checks on libraries for ldconfig. Linux/PowerPC version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2005 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 @@ -52,10 +52,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/readlinkat.c b/sysdeps/unix/sysv/linux/readlinkat.c new file mode 100644 index 0000000000..42c3877bd7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/readlinkat.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2005 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 <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sysdep.h> +#include <unistd.h> + + +/* Read the contents of the symbolic link PATH relative to FD into no + more than LEN bytes of BUF. */ +int +readlinkat (fd, path, buf, len) + int fd; + const char *path; + char *buf; + size_t len; +{ + char *pathbuf = NULL; + + if (fd != AT_FDCWD && path[0] != '/') + { + size_t pathlen = strlen (path); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + pathlen; + pathbuf = __alloca (buflen); + + __snprintf (pathbuf, buflen, procfd, fd, path); + path = pathbuf; + } + + INTERNAL_SYSCALL_DECL (err); + + int result = INTERNAL_SYSCALL (readlink, err, 3, path, buf, len); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, pathbuf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/renameat.c b/sysdeps/unix/sysv/linux/renameat.c index 9d94d5f86c..849c67b5d6 100644 --- a/sysdeps/unix/sysv/linux/renameat.c +++ b/sysdeps/unix/sysv/linux/renameat.c @@ -23,6 +23,52 @@ #include <sysdep.h> +void +attribute_hidden +__atfct_seterrno_2 (int errval, int fd1, const char *buf1, int fd2, + const char *buf2) +{ + if (errval == ENOTDIR && (buf1 != NULL || buf2 != NULL)) + { + /* This can mean either the file descriptor is invalid or + /proc is not mounted. */ + struct stat64 st; + + if (buf1 != NULL) + { + if (__fxstat64 (_STAT_VER, fd1, &st) != 0) + /* errno is already set correctly. */ + return; + + /* If /proc is not mounted there is nothing we can do. */ + if (S_ISDIR (st.st_mode) + && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 + || !S_ISDIR (st.st_mode))) + { + errval = ENOSYS; + goto out; + } + } + + if (buf2 != NULL) + { + if (__fxstat64 (_STAT_VER, fd2, &st) != 0) + /* errno is already set correctly. */ + return; + + /* If /proc is not mounted there is nothing we can do. */ + if (S_ISDIR (st.st_mode) + && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 + || !S_ISDIR (st.st_mode))) + errval = ENOSYS; + } + } + + out: + __set_errno (errval); +} + + /* Rename the file OLD relative to OLDFD to NEW relative to NEWFD. */ int renameat (oldfd, old, newfd, new) @@ -76,45 +122,8 @@ renameat (oldfd, old, newfd, new) if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) { - int errval = INTERNAL_SYSCALL_ERRNO (result, err); - if (errval == ENOTDIR && (bufnew != NULL || bufold != NULL)) - { - /* This can mean either the file descriptor is invalid or - /proc is not mounted. */ - struct stat64 st; - - if (bufnew != NULL) - { - if (__fxstat64 (_STAT_VER, newfd, &st) != 0) - /* errno is already set correctly. */ - return -1; - - /* If /proc is not mounted there is nothing we can do. */ - if (S_ISDIR (st.st_mode) - && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 - || !S_ISDIR (st.st_mode))) - { - errval = ENOSYS; - goto out; - } - } - - if (bufold != NULL) - { - if (__fxstat64 (_STAT_VER, oldfd, &st) != 0) - /* errno is already set correctly. */ - return -1; - - /* If /proc is not mounted there is nothing we can do. */ - if (S_ISDIR (st.st_mode) - && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 - || !S_ISDIR (st.st_mode))) - errval = ENOSYS; - } - } - - out: - __set_errno (errval); + __atfct_seterrno_2 (INTERNAL_SYSCALL_ERRNO (result, err), newfd, bufnew, + oldfd, bufold); result = -1; } diff --git a/sysdeps/unix/sysv/linux/s390/readelflib.c b/sysdeps/unix/sysv/linux/s390/readelflib.c index c8efcbf7ac..2782bc1e01 100644 --- a/sysdeps/unix/sysv/linux/s390/readelflib.c +++ b/sysdeps/unix/sysv/linux/s390/readelflib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2005 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 @@ -51,10 +51,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/sched_getaffinity.c b/sysdeps/unix/sysv/linux/sched_getaffinity.c index 50443c6482..c0a6eb81b9 100644 --- a/sysdeps/unix/sysv/linux/sched_getaffinity.c +++ b/sysdeps/unix/sysv/linux/sched_getaffinity.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005 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 @@ -54,5 +54,5 @@ __sched_getaffinity_old (pid_t pid, cpu_set_t *cpuset) compat_symbol (libc, __sched_getaffinity_old, sched_getaffinity, GLIBC_2_3_3); # endif #else -# include <sysdeps/generic/sched_getaffinity.c> +# include <posix/sched_getaffinity.c> #endif diff --git a/sysdeps/unix/sysv/linux/sched_setaffinity.c b/sysdeps/unix/sysv/linux/sched_setaffinity.c index 5b1b8ee878..ccd3c8f514 100644 --- a/sysdeps/unix/sysv/linux/sched_setaffinity.c +++ b/sysdeps/unix/sysv/linux/sched_setaffinity.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005 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 @@ -84,5 +84,5 @@ __sched_setaffinity_old (pid_t pid, const cpu_set_t *cpuset) compat_symbol (libc, __sched_setaffinity_old, sched_setaffinity, GLIBC_2_3_3); # endif #else -# include <sysdeps/generic/sched_setaffinity.c> +# include <posix/sched_setaffinity.c> #endif diff --git a/sysdeps/unix/sysv/linux/segfault.c b/sysdeps/unix/sysv/linux/segfault.c index 088c329b7f..a417df9c41 100644 --- a/sysdeps/unix/sysv/linux/segfault.c +++ b/sysdeps/unix/sysv/linux/segfault.c @@ -1,2 +1,2 @@ #define HAVE_PROC_SELF 1 -#include <sysdeps/generic/segfault.c> +#include <debug/segfault.c> diff --git a/sysdeps/unix/sysv/linux/sigqueue.c b/sysdeps/unix/sysv/linux/sigqueue.c index 337f886257..22a8036b64 100644 --- a/sysdeps/unix/sysv/linux/sigqueue.c +++ b/sysdeps/unix/sysv/linux/sigqueue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000, 2003, 2005 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 @@ -48,5 +48,5 @@ __sigqueue (pid, sig, val) } weak_alias (__sigqueue, sigqueue) #else -# include <sysdeps/generic/sigqueue.c> +# include <signal/sigqueue.c> #endif diff --git a/sysdeps/unix/sysv/linux/sigreturn.c b/sysdeps/unix/sysv/linux/sigreturn.c index 6b3116fef2..626b1eb8af 100644 --- a/sysdeps/unix/sysv/linux/sigreturn.c +++ b/sysdeps/unix/sysv/linux/sigreturn.c @@ -1,3 +1,3 @@ /* The sigreturn syscall cannot be explicitly called on Linux, only implicitly by returning from a signal handler. */ -#include <sysdeps/generic/sigreturn.c> +#include <signal/sigreturn.c> diff --git a/sysdeps/unix/sysv/linux/sigstack.c b/sysdeps/unix/sysv/linux/sigstack.c index 4faf4424fe..76d2126986 100644 --- a/sysdeps/unix/sysv/linux/sigstack.c +++ b/sysdeps/unix/sysv/linux/sigstack.c @@ -1,5 +1,5 @@ /* Emulate sigstack function using sigaltstack. - Copyright (C) 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -65,5 +65,5 @@ sigstack (ss, oss) link_warning (sigstack, "the `sigstack' function is dangerous. `sigaltstack' should be used instead.") #else -# include <sysdeps/generic/sigstack.c> +# include <signal/sigstack.c> #endif diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index adeadc1587..8795652766 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,2000,2002,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1997,1998,2000,2002,2003,2004, 2005 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 @@ -89,5 +89,5 @@ __sigtimedwait (set, info, timeout) libc_hidden_def (__sigtimedwait) weak_alias (__sigtimedwait, sigtimedwait) #else -# include <sysdeps/generic/sigtimedwait.c> +# include <signal/sigtimedwait.c> #endif diff --git a/sysdeps/unix/sysv/linux/sigwaitinfo.c b/sysdeps/unix/sysv/linux/sigwaitinfo.c index a51a01f20b..80790df9eb 100644 --- a/sysdeps/unix/sysv/linux/sigwaitinfo.c +++ b/sysdeps/unix/sysv/linux/sigwaitinfo.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,2000,2002,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1997,1998,2000,2002,2003,2004, 2005 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 @@ -89,6 +89,6 @@ __sigwaitinfo (set, info) libc_hidden_def (__sigwaitinfo) weak_alias (__sigwaitinfo, sigwaitinfo) #else -# include <sysdeps/generic/sigwaitinfo.c> +# include <signal/sigwaitinfo.c> #endif strong_alias (__sigwaitinfo, __libc_sigwaitinfo) diff --git a/sysdeps/unix/sysv/linux/sparc/readelflib.c b/sysdeps/unix/sysv/linux/sparc/readelflib.c index ef5fa0e2cd..e12fbc7824 100644 --- a/sysdeps/unix/sysv/linux/sparc/readelflib.c +++ b/sysdeps/unix/sysv/linux/sparc/readelflib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>, 1999 and Jakub Jelinek <jakub@redhat.com>, 1999. @@ -53,10 +53,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/symlinkat.c b/sysdeps/unix/sysv/linux/symlinkat.c new file mode 100644 index 0000000000..211b49c299 --- /dev/null +++ b/sysdeps/unix/sysv/linux/symlinkat.c @@ -0,0 +1,67 @@ +/* Copyright (C) 2005 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 <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sysdep.h> +#include <unistd.h> + + +/* Make a symbolic link to FROM named TO relative to TOFD. */ +int +symlinkat (from, tofd, to) + const char *from; + int tofd; + const char *to; +{ + char *buf = NULL; + + if (tofd != AT_FDCWD && to[0] != '/') + { + size_t tolen = strlen (to); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + tolen; + buf = __alloca (buflen); + + __snprintf (buf, buflen, procfd, tofd, to); + to = buf; + } + + INTERNAL_SYSCALL_DECL (err); + + int result = INTERNAL_SYSCALL (symlink, err, 2, from, to); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), tofd, buf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/sys/quota.h b/sysdeps/unix/sysv/linux/sys/quota.h index be2810e0c7..5aa0ec07d2 100644 --- a/sysdeps/unix/sysv/linux/sys/quota.h +++ b/sysdeps/unix/sysv/linux/sys/quota.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * Version: $Id$ */ #ifndef _SYS_QUOTA_H diff --git a/sysdeps/unix/sysv/linux/syslog.c b/sysdeps/unix/sysv/linux/syslog.c index eaaa9839dc..56828b24e3 100644 --- a/sysdeps/unix/sysv/linux/syslog.c +++ b/sysdeps/unix/sysv/linux/syslog.c @@ -7,4 +7,4 @@ # define send_flags 0 #endif -#include <sysdeps/generic/syslog.c> +#include <misc/syslog.c> diff --git a/sysdeps/unix/sysv/linux/truncate64.c b/sysdeps/unix/sysv/linux/truncate64.c index e6af2c4b04..b2ef13eaf8 100644 --- a/sysdeps/unix/sysv/linux/truncate64.c +++ b/sysdeps/unix/sysv/linux/truncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2000, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1997-2000, 2003, 2004, 2005 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 @@ -71,5 +71,5 @@ truncate64 (const char *path, off64_t length) #else /* Use the generic implementation. */ -# include <sysdeps/generic/truncate64.c> +# include <misc/truncate64.c> #endif diff --git a/sysdeps/unix/sysv/linux/updwtmp.c b/sysdeps/unix/sysv/linux/updwtmp.c index 63dd87e418..d4d3f2cb7a 100644 --- a/sysdeps/unix/sysv/linux/updwtmp.c +++ b/sysdeps/unix/sysv/linux/updwtmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. @@ -31,4 +31,4 @@ && __access (_PATH_WTMP "x", F_OK) != 0) ? _PATH_WTMP : \ file_name)))) -#include <sysdeps/generic/updwtmp.c> +#include <login/updwtmp.c> diff --git a/sysdeps/unix/sysv/linux/utmp_file.c b/sysdeps/unix/sysv/linux/utmp_file.c index 3a27802b11..958619a032 100644 --- a/sysdeps/unix/sysv/linux/utmp_file.c +++ b/sysdeps/unix/sysv/linux/utmp_file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. @@ -31,4 +31,4 @@ && __access (_PATH_WTMP "x", F_OK) != 0) ? _PATH_WTMP : \ file_name)))) -#include <sysdeps/generic/utmp_file.c> +#include <login/utmp_file.c> diff --git a/sysdeps/unix/sysv/linux/vfork.c b/sysdeps/unix/sysv/linux/vfork.c index 9b4dd5f121..c8c13d0fd5 100644 --- a/sysdeps/unix/sysv/linux/vfork.c +++ b/sysdeps/unix/sysv/linux/vfork.c @@ -1 +1 @@ -#include <sysdeps/generic/vfork.c> +#include <posix/vfork.c> diff --git a/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.c b/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.c index 7e26fecb3a..6662a94d09 100644 --- a/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.c +++ b/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.c @@ -1,5 +1,5 @@ #ifdef IS_IN_ldconfig -#include <sysdeps/i386/dl-procinfo.c> +# include <sysdeps/i386/dl-procinfo.c> #else -#include <sysdeps/generic/dl-procinfo.c> +# include <sysdeps/generic/dl-procinfo.c> #endif diff --git a/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h b/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h index b360b4288a..31455204c3 100644 --- a/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h +++ b/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h @@ -1,5 +1,5 @@ #ifdef IS_IN_ldconfig -#include <sysdeps/unix/sysv/linux/i386/dl-procinfo.h> +# include <sysdeps/unix/sysv/linux/i386/dl-procinfo.h> #else -#include <sysdeps/generic/dl-procinfo.h> +# include <sysdeps/generic/dl-procinfo.h> #endif diff --git a/sysdeps/unix/sysv/linux/x86_64/readelflib.c b/sysdeps/unix/sysv/linux/x86_64/readelflib.c index c672f1df5a..5a49af3fa6 100644 --- a/sysdeps/unix/sysv/linux/x86_64/readelflib.c +++ b/sysdeps/unix/sysv/linux/x86_64/readelflib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2001, 2002, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>, 1999 and Jakub Jelinek <jakub@redhat.com>, 1999. @@ -53,10 +53,10 @@ process_elf_file (const char *file_name, const char *lib, int *flag, #undef process_elf_file #define process_elf_file process_elf32_file #define __ELF_NATIVE_CLASS 32 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" #undef __ELF_NATIVE_CLASS #undef process_elf_file #define process_elf_file process_elf64_file #define __ELF_NATIVE_CLASS 64 -#include "sysdeps/generic/readelflib.c" +#include "elf/readelflib.c" diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 0dc2f2750e..5dfffca455 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -311,4 +311,31 @@ #endif /* __ASSEMBLER__ */ + +/* Pointer mangling support. */ +#if defined NOT_IN_libc && defined IS_IN_rtld +/* We cannot use the thread descriptor because in ld.so we use setjmp + earlier than the descriptor is initialized. */ +# ifdef __ASSEMBLER__ +# define PTR_MANGLE(reg) xorq __pointer_chk_guard_local(%rip), reg +# define PTR_DEMANGLE(reg) PTR_MANGLE (reg) +# else +# define PTR_MANGLE(reg) asm ("xorq __pointer_chk_guard_local(%%rip), %0"\ + : "=r" (reg) : "0" (reg)) +# define PTR_DEMANGLE(reg) PTR_MANGLE (reg) +# endif +#else +# ifdef __ASSEMBLER__ +# define PTR_MANGLE(reg) xorq %fs:POINTER_GUARD, reg +# define PTR_DEMANGLE(reg) PTR_MANGLE (reg) +# else +# define PTR_MANGLE(var) asm ("xorq %%fs:%c2, %0" \ + : "=r" (var) \ + : "0" (var), \ + "i" (offsetof (tcbhead_t, \ + pointer_guard))) +# define PTR_DEMANGLE(var) PTR_MANGLE (var) +# endif +#endif + #endif /* linux/x86_64/sysdep.h */ diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c new file mode 100644 index 0000000000..9332ae683e --- /dev/null +++ b/sysdeps/unix/sysv/linux/xmknodat.c @@ -0,0 +1,75 @@ +/* Copyright (C) 2005 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 <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <bp-checks.h> + +/* Create a device file named PATH relative to FD, with permission and + special bits MODE and device number DEV (which can be constructed + from major and minor device numbers with the `makedev' macro above). */ +int +__xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev) +{ + if (vers != _MKNOD_VER) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + /* We must convert the value to dev_t type used by the kernel. */ + unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1); + if (k_dev != *dev) + { + __set_errno (EINVAL); + return -1; + } + + return INLINE_SYSCALL (mknod, 3, CHECK_STRING (file), mode, + (unsigned int) k_dev); +} + +libc_hidden_def (__xmknodat) |