From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- sysdeps/mach/Subdirs | 10 +- sysdeps/mach/hppa/machine-lock.h | 63 ----- sysdeps/mach/hurd/Dist | 17 -- sysdeps/mach/hurd/Subdirs | 10 +- sysdeps/mach/hurd/alpha/Dist | 1 - sysdeps/mach/hurd/alpha/longjmp-ts.c | 3 +- sysdeps/mach/hurd/bits/ioctls.h | 1 + sysdeps/mach/hurd/bits/posix_opt.h | 108 +++++++- sysdeps/mach/hurd/bits/stat.h | 7 +- sysdeps/mach/hurd/dl-sysdep.h | 8 +- sysdeps/mach/hurd/errno.c | 1 + sysdeps/mach/hurd/euidaccess.c | 3 +- sysdeps/mach/hurd/faccessat.c | 70 +++++ sysdeps/mach/hurd/fchmodat.c | 44 ++++ sysdeps/mach/hurd/fchownat.c | 46 ++++ sysdeps/mach/hurd/fdopendir.c | 58 +++++ sysdeps/mach/hurd/fgetxattr.c | 34 +++ sysdeps/mach/hurd/flistxattr.c | 34 +++ sysdeps/mach/hurd/fork.c | 5 +- sysdeps/mach/hurd/fremovexattr.c | 34 +++ sysdeps/mach/hurd/fsetxattr.c | 34 +++ sysdeps/mach/hurd/fxstatat.c | 33 +++ sysdeps/mach/hurd/fxstatat64.c | 46 ++++ sysdeps/mach/hurd/getdents.c | 2 +- sysdeps/mach/hurd/getpeername.c | 14 +- sysdeps/mach/hurd/getresgid.c | 14 +- sysdeps/mach/hurd/getresuid.c | 14 +- sysdeps/mach/hurd/getsid.c | 3 + sysdeps/mach/hurd/getxattr.c | 35 +++ sysdeps/mach/hurd/hppa/bits/sigcontext.h | 94 ------- sysdeps/mach/hurd/hppa/trampoline.c | 230 ----------------- sysdeps/mach/hurd/i386/Dist | 3 - sysdeps/mach/hurd/i386/init-first.c | 25 +- sysdeps/mach/hurd/i386/longjmp-ts.c | 3 +- sysdeps/mach/hurd/i386/tls.h | 4 +- sysdeps/mach/hurd/i386/trampoline.c | 7 +- sysdeps/mach/hurd/ifreq.c | 65 +++++ sysdeps/mach/hurd/ifreq.h | 80 ------ sysdeps/mach/hurd/init-posix.c | 2 +- sysdeps/mach/hurd/ioctl.c | 22 +- sysdeps/mach/hurd/jmp-unwind.c | 20 +- sysdeps/mach/hurd/lgetxattr.c | 36 +++ sysdeps/mach/hurd/linkat.c | 66 +++++ sysdeps/mach/hurd/listxattr.c | 35 +++ sysdeps/mach/hurd/lsetxattr.c | 37 +++ sysdeps/mach/hurd/mig-reply.c | 4 +- sysdeps/mach/hurd/mips/Dist | 3 - sysdeps/mach/hurd/mips/bits/sigcontext.h | 80 ------ sysdeps/mach/hurd/mips/dl-machine.c | 132 ---------- sysdeps/mach/hurd/mips/exc2signal.c | 97 ------- sysdeps/mach/hurd/mips/init-fault.c | 41 --- sysdeps/mach/hurd/mips/init-first.c | 414 ------------------------------ sysdeps/mach/hurd/mips/intr-msg.h | 127 --------- sysdeps/mach/hurd/mips/longjmp-ctx.c | 41 --- sysdeps/mach/hurd/mips/longjmp-ts.c | 45 ---- sysdeps/mach/hurd/mips/sigreturn.c | 223 ---------------- sysdeps/mach/hurd/mips/trampoline.c | 292 --------------------- sysdeps/mach/hurd/mkdirat.c | 42 +++ sysdeps/mach/hurd/nfs/nfs.h | 32 --- sysdeps/mach/hurd/open.c | 8 +- sysdeps/mach/hurd/open64.c | 1 + sysdeps/mach/hurd/openat.c | 62 +++++ sysdeps/mach/hurd/openat64.c | 1 + sysdeps/mach/hurd/opendir.c | 75 +++--- sysdeps/mach/hurd/powerpc/Dist | 1 - sysdeps/mach/hurd/powerpc/longjmp-ts.c | 3 +- sysdeps/mach/hurd/powerpc/register-dump.h | 4 +- sysdeps/mach/hurd/powerpc/trampoline.c | 7 +- sysdeps/mach/hurd/ppoll.c | 30 +++ sysdeps/mach/hurd/profil.c | 4 +- sysdeps/mach/hurd/readdir64_r.c | 2 +- sysdeps/mach/hurd/recv.c | 6 +- sysdeps/mach/hurd/removexattr.c | 35 +++ sysdeps/mach/hurd/setitimer.c | 12 +- sysdeps/mach/hurd/setresgid.c | 11 +- sysdeps/mach/hurd/setresuid.c | 11 +- sysdeps/mach/hurd/setxattr.c | 36 +++ sysdeps/mach/hurd/sigaltstack.c | 2 +- sysdeps/mach/hurd/symlinkat.c | 74 ++++++ sysdeps/mach/hurd/tls.h | 9 +- sysdeps/mach/hurd/unlinkat.c | 55 ++++ sysdeps/mach/hurd/xmknod.c | 86 +------ sysdeps/mach/hurd/xmknodat.c | 118 +++++++++ sysdeps/mach/i386/syscall.S | 3 +- sysdeps/mach/mips/Dist | 1 - sysdeps/mach/mips/Makefile | 3 - sysdeps/mach/mips/cacheflush.c | 44 ---- sysdeps/mach/mips/machine-lock.h | 92 ------- sysdeps/mach/mips/machine-sp.h | 38 --- sysdeps/mach/mips/syscall.S | 48 ---- sysdeps/mach/mips/sysdep.h | 83 ------ sysdeps/mach/mips/thread_state.h | 42 --- sysdeps/mach/msync.c | 4 +- sysdeps/mach/sched_yield.c | 3 +- sysdeps/mach/sys/reboot.h | 136 +--------- 95 files changed, 1479 insertions(+), 2725 deletions(-) delete mode 100644 sysdeps/mach/hppa/machine-lock.h delete mode 100644 sysdeps/mach/hurd/Dist delete mode 100644 sysdeps/mach/hurd/alpha/Dist create mode 100644 sysdeps/mach/hurd/errno.c create mode 100644 sysdeps/mach/hurd/faccessat.c create mode 100644 sysdeps/mach/hurd/fchmodat.c create mode 100644 sysdeps/mach/hurd/fchownat.c create mode 100644 sysdeps/mach/hurd/fdopendir.c create mode 100644 sysdeps/mach/hurd/fgetxattr.c create mode 100644 sysdeps/mach/hurd/flistxattr.c create mode 100644 sysdeps/mach/hurd/fremovexattr.c create mode 100644 sysdeps/mach/hurd/fsetxattr.c create mode 100644 sysdeps/mach/hurd/fxstatat.c create mode 100644 sysdeps/mach/hurd/fxstatat64.c create mode 100644 sysdeps/mach/hurd/getxattr.c delete mode 100644 sysdeps/mach/hurd/hppa/bits/sigcontext.h delete mode 100644 sysdeps/mach/hurd/hppa/trampoline.c delete mode 100644 sysdeps/mach/hurd/i386/Dist create mode 100644 sysdeps/mach/hurd/ifreq.c delete mode 100644 sysdeps/mach/hurd/ifreq.h create mode 100644 sysdeps/mach/hurd/lgetxattr.c create mode 100644 sysdeps/mach/hurd/linkat.c create mode 100644 sysdeps/mach/hurd/listxattr.c create mode 100644 sysdeps/mach/hurd/lsetxattr.c delete mode 100644 sysdeps/mach/hurd/mips/Dist delete mode 100644 sysdeps/mach/hurd/mips/bits/sigcontext.h delete mode 100644 sysdeps/mach/hurd/mips/dl-machine.c delete mode 100644 sysdeps/mach/hurd/mips/exc2signal.c delete mode 100644 sysdeps/mach/hurd/mips/init-fault.c delete mode 100644 sysdeps/mach/hurd/mips/init-first.c delete mode 100644 sysdeps/mach/hurd/mips/intr-msg.h delete mode 100644 sysdeps/mach/hurd/mips/longjmp-ctx.c delete mode 100644 sysdeps/mach/hurd/mips/longjmp-ts.c delete mode 100644 sysdeps/mach/hurd/mips/sigreturn.c delete mode 100644 sysdeps/mach/hurd/mips/trampoline.c create mode 100644 sysdeps/mach/hurd/mkdirat.c delete mode 100644 sysdeps/mach/hurd/nfs/nfs.h create mode 100644 sysdeps/mach/hurd/open64.c create mode 100644 sysdeps/mach/hurd/openat.c create mode 100644 sysdeps/mach/hurd/openat64.c delete mode 100644 sysdeps/mach/hurd/powerpc/Dist create mode 100644 sysdeps/mach/hurd/ppoll.c create mode 100644 sysdeps/mach/hurd/removexattr.c create mode 100644 sysdeps/mach/hurd/setxattr.c create mode 100644 sysdeps/mach/hurd/symlinkat.c create mode 100644 sysdeps/mach/hurd/unlinkat.c create mode 100644 sysdeps/mach/hurd/xmknodat.c delete mode 100644 sysdeps/mach/mips/Dist delete mode 100644 sysdeps/mach/mips/Makefile delete mode 100644 sysdeps/mach/mips/cacheflush.c delete mode 100644 sysdeps/mach/mips/machine-lock.h delete mode 100644 sysdeps/mach/mips/machine-sp.h delete mode 100644 sysdeps/mach/mips/syscall.S delete mode 100644 sysdeps/mach/mips/sysdep.h delete mode 100644 sysdeps/mach/mips/thread_state.h (limited to 'sysdeps/mach') diff --git a/sysdeps/mach/Subdirs b/sysdeps/mach/Subdirs index fc6ac35d83..24fa4a3c98 100644 --- a/sysdeps/mach/Subdirs +++ b/sysdeps/mach/Subdirs @@ -1 +1,9 @@ -mach +# This file says that the mach subdirectory should appear before all others. +# The mach and hurd subdirectories have many generated header files which +# much of the rest of the library depends on, so it is best to build them +# first (and mach before hurd, at that). The before-compile additions in +# sysdeps/{mach,hurd}/Makefile should make it reliably work for these files +# not to exist when making in other directories, but it will be slower that +# way with more somewhat expensive `make' invocations. + +first mach diff --git a/sysdeps/mach/hppa/machine-lock.h b/sysdeps/mach/hppa/machine-lock.h deleted file mode 100644 index 8c71d40a5a..0000000000 --- a/sysdeps/mach/hppa/machine-lock.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Machine-specific definition for spin locks. HPPA version. - Copyright (C) 1995, 1997 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. */ - -#ifndef _MACHINE_LOCK_H -#define _MACHINE_LOCK_H - -/* The type of a spin lock variable. */ - -typedef __volatile int __spin_lock_t __attribute__ ((__aligned__ (16))); - -/* Value to initialize `__spin_lock_t' variables to. */ - -#define __SPIN_LOCK_INITIALIZER -1 - - -#ifndef _EXTERN_INLINE -#define _EXTERN_INLINE extern __inline -#endif - -/* Unlock LOCK. */ - -_EXTERN_INLINE void -__spin_unlock (__spin_lock_t *__lock) -{ - *__lock = -1; -} - -/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ - -_EXTERN_INLINE int -__spin_try_lock (__spin_lock_t *__lock) -{ - register int __result; - __asm__ __volatile__ ("ldcws %0, %1" : "=m" (*__lock), "=r" (__result)); - return __result != 0; -} - -/* Return nonzero if LOCK is locked. */ - -_EXTERN_INLINE int -__spin_lock_locked (__spin_lock_t *__lock) -{ - return *__lock == 0; -} - - -#endif /* machine-lock.h */ diff --git a/sysdeps/mach/hurd/Dist b/sysdeps/mach/hurd/Dist deleted file mode 100644 index 52c84297cb..0000000000 --- a/sysdeps/mach/hurd/Dist +++ /dev/null @@ -1,17 +0,0 @@ -cthreads.c -errlist.c -errnos.awk -err_hurd.sub -libc-ldscript -libc_p-ldscript -bits/libc-tsd.h -net/ethernet.h -net/if_arp.h -net/if_ether.h -net/if_ppp.h -net/route.h -nfs/nfs.h -set-init.c -siglist.h -statfsconv.c -xstatconv.c diff --git a/sysdeps/mach/hurd/Subdirs b/sysdeps/mach/hurd/Subdirs index 16b8348437..7a7757582a 100644 --- a/sysdeps/mach/hurd/Subdirs +++ b/sysdeps/mach/hurd/Subdirs @@ -1 +1,9 @@ -hurd +# This file says that the hurd subdirectory should appear before all others. +# The mach and hurd subdirectories have many generated header files which +# much of the rest of the library depends on, so it is best to build them +# first (and mach before hurd, at that). The before-compile additions in +# sysdeps/{mach,hurd}/Makefile should make it reliably work for these files +# not to exist when making in other directories, but it will be slower that +# way with more somewhat expensive `make' invocations. + +first hurd diff --git a/sysdeps/mach/hurd/alpha/Dist b/sysdeps/mach/hurd/alpha/Dist deleted file mode 100644 index c58180257e..0000000000 --- a/sysdeps/mach/hurd/alpha/Dist +++ /dev/null @@ -1 +0,0 @@ -static-start.S diff --git a/sysdeps/mach/hurd/alpha/longjmp-ts.c b/sysdeps/mach/hurd/alpha/longjmp-ts.c index b271d6d2a9..f472dbcb30 100644 --- a/sysdeps/mach/hurd/alpha/longjmp-ts.c +++ b/sysdeps/mach/hurd/alpha/longjmp-ts.c @@ -1,5 +1,5 @@ /* Perform a `longjmp' on a Mach thread_state. Alpha version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -19,6 +19,7 @@ #include #include +#include #include diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h index 206058bf2f..06a73df75e 100644 --- a/sysdeps/mach/hurd/bits/ioctls.h +++ b/sysdeps/mach/hurd/bits/ioctls.h @@ -226,6 +226,7 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ #define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */ #define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet address */ +#define SIOCGIFHWADDR _IOWR('i',39, struct ifreq) /* get hwaddress */ #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */ #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */ diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h index 326bebff7f..6747bc276e 100644 --- a/sysdeps/mach/hurd/bits/posix_opt.h +++ b/sysdeps/mach/hurd/bits/posix_opt.h @@ -1,5 +1,5 @@ /* Define POSIX options for GNU/Hurd. - Copyright (C) 1998,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1998,2000,2001,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 @@ -31,13 +31,6 @@ /* Processes have a saved set-user-ID and a saved set-group-ID. */ #define _POSIX_SAVED_IDS 1 -#if 0 /* XXX implement aio_* */ -/* Asynchronous I/O is supported. */ -#define _POSIX_ASYNCHRONOUS_IO 1 -/* Alternative name for Unix98. */ -#define _LFS_ASYNCHRONOUS_IO _POSIX_ASYNCHRONOUS_IO -#endif - /* Synchronizing file data is supported, but msync is missing. */ #undef _POSIX_SYNCHRONIZED_IO @@ -47,15 +40,15 @@ /* Mapping of files to memory is supported. */ #define _POSIX_MAPPED_FILES 200112L +/* Locking of all memory could be supported in future. */ +#define _POSIX_MEMLOCK 0 + /* Locking of ranges of memory is supported. */ #define _POSIX_MEMLOCK_RANGE 200112L /* Setting of memory protections is supported. */ #define _POSIX_MEMORY_PROTECTION 200112L -/* POSIX.4 shared memory objects are supported (using regular files). */ -#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_MAPPED_FILES - /* Elements of the `c_cc' member of `struct termios' structure can be disabled by using the value _POSIX_VDISABLE. */ #define _POSIX_VDISABLE ((unsigned char) -1) @@ -67,13 +60,106 @@ #undef _POSIX_NO_TRUNC /* Overlong file names get error? */ #undef _POSIX_SYNC_IO /* File supports O_SYNC et al? */ + +/* We do not have the POSIX threads interface. */ +#define _POSIX_THREADS -1 + +/* We have the reentrant functions described in POSIX. */ +#define _POSIX_REENTRANT_FUNCTIONS 1 +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +/* These are all things that won't be supported when _POSIX_THREADS is not. */ +#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 +#define _POSIX_THREAD_ATTR_STACKSIZE -1 +#define _POSIX_THREAD_ATTR_STACKADDR -1 +#define _POSIX_SEMAPHORES -1 + +/* Real-time signals are not yet supported. */ +#define _POSIX_REALTIME_SIGNALS -1 + +/* Asynchronous I/O might supported with the existing ABI. */ +#define _POSIX_ASYNCHRONOUS_IO 0 +/* Alternative name for Unix98. */ +#define _LFS_ASYNCHRONOUS_IO _POSIX_ASYNCHRONOUS_IO + +/* The LFS support in asynchronous I/O is also available. */ +#define _LFS64_ASYNCHRONOUS_IO _POSIX_ASYNCHRONOUS_IO + +/* The rest of the LFS is also available. */ +#define _LFS_LARGEFILE 1 +#define _LFS64_LARGEFILE 1 +#define _LFS64_STDIO 1 + +/* POSIX.4 shared memory objects are supported (using regular files). */ +#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_MAPPED_FILES + +/* CPU-time clocks support needs to be checked at runtime. */ +#define _POSIX_CPUTIME 0 + +/* Clock support in threads must be also checked at runtime. */ +#define _POSIX_THREAD_CPUTIME 0 + /* GNU libc provides regular expression handling. */ #define _POSIX_REGEXP 1 +/* Reader/Writer locks are not available. */ +#define _POSIX_READER_WRITER_LOCKS -1 + /* We have a POSIX shell. */ #define _POSIX_SHELL 1 +/* We cannot support the Timeouts option without _POSIX_THREADS. */ +#define _POSIX_TIMEOUTS -1 + /* The `spawn' function family is supported. */ #define _POSIX_SPAWN 200112L +/* We do not have POSIX timers, but could in future without ABI change. */ +#define _POSIX_TIMERS 0 + +/* The barrier functions are not available. */ +#define _POSIX_BARRIERS -1 + +/* POSIX message queues could be available in future. */ +#define _POSIX_MESSAGE_PASSING 0 + +/* Thread process-shared synchronization is not supported. */ +#define _POSIX_THREAD_PROCESS_SHARED -1 + +/* The monotonic clock might be available. */ +#define _POSIX_MONOTONIC_CLOCK 0 + +/* The clock selection interfaces are available. */ +#define _POSIX_CLOCK_SELECTION 200112L + +/* Advisory information interfaces could be available in future. */ +#define _POSIX_ADVISORY_INFO 0 + +/* IPv6 support is available. */ +#define _POSIX_IPV6 200112L + +/* Raw socket support is available. */ +#define _POSIX_RAW_SOCKETS 200112L + +/* We have at least one terminal. */ +#define _POSIX2_CHAR_TERM 200112L + +/* Neither process nor thread sporadic server interfaces is available. */ +#define _POSIX_SPORADIC_SERVER -1 +#define _POSIX_THREAD_SPORADIC_SERVER -1 + +/* trace.h is not available. */ +#define _POSIX_TRACE -1 +#define _POSIX_TRACE_EVENT_FILTER -1 +#define _POSIX_TRACE_INHERIT -1 +#define _POSIX_TRACE_LOG -1 + +/* Typed memory objects are not available. */ +#define _POSIX_TYPED_MEMORY_OBJECTS -1 + +/* No support for priority inheritance or protection so far. */ +#define _POSIX_THREAD_PRIO_INHERIT -1 +#define _POSIX_THREAD_PRIO_PROTECT -1 + + #endif /* bits/posix_opt.h */ diff --git a/sysdeps/mach/hurd/bits/stat.h b/sysdeps/mach/hurd/bits/stat.h index 172bc5ea8e..c3f96660cc 100644 --- a/sysdeps/mach/hurd/bits/stat.h +++ b/sysdeps/mach/hurd/bits/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 93, 94, 96, 97, 99, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1992,93,94,96,97,99,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 @@ -182,8 +182,11 @@ struct stat64 /* All the bits relevant to translators */ #define S_ITRANS 000070000000 +/* Definitely no mmaps to this. */ +#define S_IMMAP0 000100000000 + /* ALL the unused bits. */ -#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE| \ +#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0| \ S_IUSEUNK|S_IUNKNOWN|07777)) #endif diff --git a/sysdeps/mach/hurd/dl-sysdep.h b/sysdeps/mach/hurd/dl-sysdep.h index 2dc9b0a910..4b21b779ef 100644 --- a/sysdeps/mach/hurd/dl-sysdep.h +++ b/sysdeps/mach/hurd/dl-sysdep.h @@ -1,5 +1,5 @@ /* System-specific settings for dynamic linker code. Hurd 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 @@ -23,3 +23,9 @@ (open, mmap, etc). */ #define RTLD_PRIVATE_ERRNO 0 + +#ifdef SHARED +/* _dl_argv cannot be attribute_relro, because the stack-switching + libc initializer for using cthreads might write into it. */ +# define DL_ARGV_NOT_RELRO 1 +#endif diff --git a/sysdeps/mach/hurd/errno.c b/sysdeps/mach/hurd/errno.c new file mode 100644 index 0000000000..a29091b5e2 --- /dev/null +++ b/sysdeps/mach/hurd/errno.c @@ -0,0 +1 @@ +/* No definition of `errno' variable on the Hurd. */ diff --git a/sysdeps/mach/hurd/euidaccess.c b/sysdeps/mach/hurd/euidaccess.c index 4e72e2abb3..57f2a015cc 100644 --- a/sysdeps/mach/hurd/euidaccess.c +++ b/sysdeps/mach/hurd/euidaccess.c @@ -1,5 +1,5 @@ /* Test for access to FILE using effective UID and GID. Hurd version. - Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1991, 1995, 1997, 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 @@ -57,3 +57,4 @@ __euidaccess (file, type) return 0; } weak_alias (__euidaccess, euidaccess) +weak_alias (__euidaccess, eaccess) diff --git a/sysdeps/mach/hurd/faccessat.c b/sysdeps/mach/hurd/faccessat.c new file mode 100644 index 0000000000..bb3c9fe19f --- /dev/null +++ b/sysdeps/mach/hurd/faccessat.c @@ -0,0 +1,70 @@ +/* Test for access to file, relative to open directory. Hurd version. + 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 +#include +#include +#include +#include +#include +#include + +int +faccessat (fd, file, type, flag) + int fd; + const char *file; + int type; + int flag; +{ + error_t err; + file_t port; + int allowed, flags; + + if ((flag & AT_EACCESS) == 0) + { + if (fd == AT_FDCWD || file[0] == '/') + return __access (file, type); + __set_errno (ENOTSUP); /* XXX later */ + return -1; + } + + port = __file_name_lookup_at (fd, flag &~ AT_EACCESS, file, 0, 0); + if (port == MACH_PORT_NULL) + return -1; + + /* Find out what types of access we are allowed to this file. */ + err = __file_check_access (port, &allowed); + __mach_port_deallocate (__mach_task_self (), port); + if (err) + return __hurd_fail (err); + + flags = 0; + if (type & R_OK) + flags |= O_READ; + if (type & W_OK) + flags |= O_WRITE; + if (type & X_OK) + flags |= O_EXEC; + + if (flags & ~allowed) + /* We are not allowed all the requested types of access. */ + return __hurd_fail (EACCES); + + return 0; +} diff --git a/sysdeps/mach/hurd/fchmodat.c b/sysdeps/mach/hurd/fchmodat.c new file mode 100644 index 0000000000..d27e845274 --- /dev/null +++ b/sysdeps/mach/hurd/fchmodat.c @@ -0,0 +1,44 @@ +/* Change the protections of file relative to open directory. Hurd version. + 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 +#include +#include +#include +#include +#include +#include + +int +fchmodat (fd, file, mode, flag) + int fd; + const char *file; + mode_t mode; + int flag; +{ + error_t err; + file_t port = __file_name_lookup_at (fd, flag, file, 0, 0); + if (port == MACH_PORT_NULL) + return -1; + err = __file_chmod (port, mode); + __mach_port_deallocate (__mach_task_self (), port); + if (err) + return __hurd_fail (err); + return 0; +} diff --git a/sysdeps/mach/hurd/fchownat.c b/sysdeps/mach/hurd/fchownat.c new file mode 100644 index 0000000000..1b99b29272 --- /dev/null +++ b/sysdeps/mach/hurd/fchownat.c @@ -0,0 +1,46 @@ +/* Change owner and group of a file relative to open directory. Hurd version. + 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 +#include +#include +#include +#include +#include +#include + +/* Change the owner and group of FILE. */ +int +fchownat (fd, file, owner, group, flag) + int fd; + const char *file; + uid_t owner; + gid_t group; + int flag; +{ + error_t err; + file_t port = __file_name_lookup_at (fd, flag, file, 0, 0); + if (port == MACH_PORT_NULL) + return -1; + err = __file_chown (port, owner, group); + __mach_port_deallocate (__mach_task_self (), port); + if (err) + return __hurd_fail (err); + return 0; +} diff --git a/sysdeps/mach/hurd/fdopendir.c b/sysdeps/mach/hurd/fdopendir.c new file mode 100644 index 0000000000..016f825f1d --- /dev/null +++ b/sysdeps/mach/hurd/fdopendir.c @@ -0,0 +1,58 @@ +/* Open a directory stream from a file descriptor. Hurd version. + Copyright (C) 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 + 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 +#include +#include +#include +#include + +DIR *_hurd_fd_opendir (struct hurd_fd *d); /* opendir.c */ + +/* Open a directory stream on FD. */ +DIR * +__fdopendir (int fd) +{ + struct hurd_fd *d = _hurd_fd_get (fd); + + if (d == NULL) + { + errno = EBADF; + return NULL; + } + + /* Ensure that it's a directory. */ + error_t err = HURD_FD_PORT_USE + (d, ({ + file_t dir = __file_name_lookup_under (port, "/", + O_DIRECTORY | O_NOTRANS, 0);; + if (dir != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), dir); + dir != MACH_PORT_NULL ? 0 : errno; + })); + + if (err) + { + errno = err; + return NULL; + } + + return _hurd_fd_opendir (d); +} +weak_alias (__fdopendir, fdopendir) diff --git a/sysdeps/mach/hurd/fgetxattr.c b/sysdeps/mach/hurd/fgetxattr.c new file mode 100644 index 0000000000..2eb6db06c7 --- /dev/null +++ b/sysdeps/mach/hurd/fgetxattr.c @@ -0,0 +1,34 @@ +/* Access to extended attributes on files. Hurd version. + Copyright (C) 2004 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 +#include +#include +#include +#include + +ssize_t +fgetxattr (int fd, const char *name, void *value, size_t size) +{ + error_t err; + + err = HURD_DPORT_USE (fd, _hurd_xattr_get (port, name, value, &size)); + + return err ? __hurd_dfail (fd, err) : size; +} diff --git a/sysdeps/mach/hurd/flistxattr.c b/sysdeps/mach/hurd/flistxattr.c new file mode 100644 index 0000000000..a577e4e393 --- /dev/null +++ b/sysdeps/mach/hurd/flistxattr.c @@ -0,0 +1,34 @@ +/* Access to extended attributes on files. Hurd version. + 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 +#include +#include +#include +#include + +ssize_t +flistxattr (int fd, char *list, size_t size) +{ + error_t err; + + err = HURD_DPORT_USE (fd, _hurd_xattr_list (port, list, &size)); + + return err ? __hurd_dfail (fd, err) : size; +} diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c index 8728596915..fa7da60204 100644 --- a/sysdeps/mach/hurd/fork.c +++ b/sysdeps/mach/hurd/fork.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1994,95,96,97,99,2001,02, 04 Free Software Foundation, Inc. +/* Copyright (C) 1994,1995,1996,1997,1999,2001,2002,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 @@ -21,7 +22,7 @@ #include #include #include -#include "thread_state.h" +#include #include /* For stack growth direction. */ #include "set-hooks.h" #include diff --git a/sysdeps/mach/hurd/fremovexattr.c b/sysdeps/mach/hurd/fremovexattr.c new file mode 100644 index 0000000000..5d3aca6093 --- /dev/null +++ b/sysdeps/mach/hurd/fremovexattr.c @@ -0,0 +1,34 @@ +/* Access to extended attributes on files. Hurd version. + 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 +#include +#include +#include +#include + +int +fremovexattr (int fd, const char *name) +{ + error_t err; + + err = HURD_DPORT_USE (fd, _hurd_xattr_remove (port, name)); + + return err ? __hurd_dfail (fd, err) : 0; +} diff --git a/sysdeps/mach/hurd/fsetxattr.c b/sysdeps/mach/hurd/fsetxattr.c new file mode 100644 index 0000000000..db8b676a06 --- /dev/null +++ b/sysdeps/mach/hurd/fsetxattr.c @@ -0,0 +1,34 @@ +/* Access to extended attributes on files. Hurd version. + 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 +#include +#include +#include +#include + +ssize_t +fsetxattr (int fd, const char *name, const void *value, size_t size, int flags) +{ + error_t err; + + err = HURD_DPORT_USE (fd, _hurd_xattr_set (port, name, value, size, flags)); + + return err ? __hurd_dfail (fd, err) : 0; +} diff --git a/sysdeps/mach/hurd/fxstatat.c b/sysdeps/mach/hurd/fxstatat.c new file mode 100644 index 0000000000..dd9d2796eb --- /dev/null +++ b/sysdeps/mach/hurd/fxstatat.c @@ -0,0 +1,33 @@ +/* Get information about file named relative to open directory. Hurd version. + 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 +#include +#include + +#include "xstatconv.c" + +int +__fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag) +{ + struct stat64 buf64; + return (__fxstatat64 (vers, fd, filename, &buf64, flag) + ?: xstat64_conv (buf, &buf64)); +} +libc_hidden_def (__fxstatat) diff --git a/sysdeps/mach/hurd/fxstatat64.c b/sysdeps/mach/hurd/fxstatat64.c new file mode 100644 index 0000000000..6862e80d52 --- /dev/null +++ b/sysdeps/mach/hurd/fxstatat64.c @@ -0,0 +1,46 @@ +/* Get information about file named relative to open directory. Hurd version. + 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 +#include +#include +#include +#include +#include + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf, + int flag) +{ + error_t err; + io_t port; + + if (vers != _STAT_VER) + return __hurd_fail (EINVAL); + + port = __file_name_lookup_at (fd, flag, filename, 0, 0); + if (port == MACH_PORT_NULL) + return -1; + + err = __io_stat (port, buf); + __mach_port_deallocate (__mach_task_self (), port); + + return __hurd_fail (err); +} diff --git a/sysdeps/mach/hurd/getdents.c b/sysdeps/mach/hurd/getdents.c index 4775f983b4..d15be3b8f3 100644 --- a/sysdeps/mach/hurd/getdents.c +++ b/sysdeps/mach/hurd/getdents.c @@ -1 +1 @@ -#include +#include diff --git a/sysdeps/mach/hurd/getpeername.c b/sysdeps/mach/hurd/getpeername.c index 2e4f9f6a9d..325b6fd75d 100644 --- a/sysdeps/mach/hurd/getpeername.c +++ b/sysdeps/mach/hurd/getpeername.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1994, 1997, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1992,1994,1997,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 @@ -47,14 +47,22 @@ __getpeername (int fd, __SOCKADDR_ARG addrarg, socklen_t *len) if (*len > buflen) *len = buflen; - + if (buf != (char *) addr) { memcpy (addr, buf, *len); __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen); } - addr->sa_family = type; + const sa_family_t family = type; + if (*len > offsetof (struct sockaddr, sa_family)) + { + if (*len < (char *) (&addr->sa_family + 1) - (char *) addr) + memcpy (&addr->sa_family, &family, + *len - offsetof (struct sockaddr, sa_family)); + else + addr->sa_family = family; + } return 0; } diff --git a/sysdeps/mach/hurd/getresgid.c b/sysdeps/mach/hurd/getresgid.c index a96aa49369..7847d213c4 100644 --- a/sysdeps/mach/hurd/getresgid.c +++ b/sysdeps/mach/hurd/getresgid.c @@ -1,5 +1,5 @@ -/* getresgid -- fetch effective group ID, real group ID, and saved-set group ID - Copyright (C) 2002 Free Software Foundation, Inc. +/* getresgid -- fetch real group ID, effective group ID, and saved-set group ID + Copyright (C) 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 @@ -22,13 +22,13 @@ #include #include -/* Fetch the effective group ID, real group ID, and saved-set group ID, +/* Fetch the real group ID, effective group ID, and saved-set group ID, of the calling process. */ int -__getresgid (gid_t *egid, gid_t *rgid, gid_t *sgid) +__getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid) { error_t err; - gid_t eff, real, saved; + gid_t real, eff, saved; HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_id.lock); @@ -42,8 +42,8 @@ __getresgid (gid_t *egid, gid_t *rgid, gid_t *sgid) else { real = _hurd_id.aux.gids[0]; - saved = _hurd_id.aux.ngids < 2 ? real :_hurd_id.aux.gids[1]; eff = _hurd_id.gen.ngids < 1 ? real : _hurd_id.gen.gids[0]; + saved = _hurd_id.aux.ngids < 2 ? real : _hurd_id.aux.gids[1]; } } @@ -53,8 +53,8 @@ __getresgid (gid_t *egid, gid_t *rgid, gid_t *sgid) if (err) return __hurd_fail (err); - *egid = eff; *rgid = real; + *egid = eff; *sgid = saved; return 0; } diff --git a/sysdeps/mach/hurd/getresuid.c b/sysdeps/mach/hurd/getresuid.c index f4bfaeaf56..668e463a39 100644 --- a/sysdeps/mach/hurd/getresuid.c +++ b/sysdeps/mach/hurd/getresuid.c @@ -1,5 +1,5 @@ -/* getresuid -- fetch effective user ID, real user ID, and saved-set user ID - Copyright (C) 2002 Free Software Foundation, Inc. +/* getresuid -- fetch real user ID, effective user ID, and saved-set user ID + Copyright (C) 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 @@ -22,13 +22,13 @@ #include #include -/* Fetch the effective user ID, real user ID, and saved-set user ID, +/* Fetch the real user ID, effective user ID, and saved-set user ID, of the calling process. */ int -__getresuid (uid_t *euid, uid_t *ruid, uid_t *suid) +__getresuid (uid_t *ruid, uid_t *euid, uid_t *suid) { error_t err; - uid_t eff, real, saved; + uid_t real, eff, saved; HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_id.lock); @@ -42,8 +42,8 @@ __getresuid (uid_t *euid, uid_t *ruid, uid_t *suid) else { real = _hurd_id.aux.uids[0]; - saved = _hurd_id.aux.nuids < 2 ? real :_hurd_id.aux.uids[1]; eff = _hurd_id.gen.nuids < 1 ? real : _hurd_id.gen.uids[0]; + saved = _hurd_id.aux.nuids < 2 ? real : _hurd_id.aux.uids[1]; } } @@ -53,8 +53,8 @@ __getresuid (uid_t *euid, uid_t *ruid, uid_t *suid) if (err) return __hurd_fail (err); - *euid = eff; *ruid = real; + *euid = eff; *suid = saved; return 0; } diff --git a/sysdeps/mach/hurd/getsid.c b/sysdeps/mach/hurd/getsid.c index 57c10c58b7..9dcfa90fde 100644 --- a/sysdeps/mach/hurd/getsid.c +++ b/sysdeps/mach/hurd/getsid.c @@ -28,6 +28,9 @@ getsid (pid_t pid) error_t err; pid_t sid; + if (pid == 0) + pid = _hurd_pid; + err = __USEPORT (PROC, __proc_getsid (port, pid, &sid)); if (err) return (pid_t) __hurd_fail (err); diff --git a/sysdeps/mach/hurd/getxattr.c b/sysdeps/mach/hurd/getxattr.c new file mode 100644 index 0000000000..8f688a1d2f --- /dev/null +++ b/sysdeps/mach/hurd/getxattr.c @@ -0,0 +1,35 @@ +/* Access to extended attributes on files. Hurd version. + Copyright (C) 2004 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 +#include +#include +#include + +ssize_t +getxattr (const char *path, const char *name, void *value, size_t size) +{ + error_t err; + file_t port = __file_name_lookup (path, 0, 0); + if (port == MACH_PORT_NULL) + return -1; + err = _hurd_xattr_get (port, name, value, &size); + __mach_port_deallocate (__mach_task_self (), port); + return err ? __hurd_fail (err) : size; +} diff --git a/sysdeps/mach/hurd/hppa/bits/sigcontext.h b/sysdeps/mach/hurd/hppa/bits/sigcontext.h deleted file mode 100644 index 5db43fc22c..0000000000 --- a/sysdeps/mach/hurd/hppa/bits/sigcontext.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Machine-dependent signal context structure for GNU Hurd. HPPA version. - Copyright (C) 1995,97,2001 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. */ - -#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H -# error "Never use directly; include instead." -#endif - -#ifndef sc_parisc_thread_state - -/* Signal handlers are actually called: - void handler (int sig, int code, struct sigcontext *scp); */ - -/* State of this thread when the signal was taken. */ -struct sigcontext - { - /* These first members are machine-independent. */ - - int sc_onstack; /* Nonzero if running on sigstack. */ - __sigset_t sc_mask; /* Blocked signals to restore. */ - - /* MiG reply port this thread is using. */ - unsigned int sc_reply_port; - - /* Port this thread is doing an interruptible RPC on. */ - unsigned int sc_intr_port; - - /* Error code associated with this signal (interpreted as `error_t'). */ - int sc_error; - - /* All following members are machine-dependent. The rest of this - structure is written to be laid out identically to a `struct - parisc_thread_state'. trampoline.c knows this, so it must be - changed if this changes. */ - -#define sc_parisc_thread_state sc_flags /* Beginning of correspondence. */ - /* "General" registers $1..$31. */ - unsigned int sc_regs[31]; - - /* Control registers. */ - unsigned int sc_cr11; /* sar */ - /* These four registers make up the PC. */ - unsigned int iioq_head; - unsigned int iisq_head; - unsigned int iioq_tail; - unsigned int iisq_tail; - unsigned int sc_cr15; - unsigned int sc_cr19; - unsigned int sc_cr20; - unsigned int sc_cr21; - unsigned int sc_cr22; /* ipsw */ - unsigned int sc_bsd_goto; /* unused */ - unsigned int sc_sr4; - unsigned int sc_sr0; - unsigned int sc_sr1; - unsigned int sc_sr2; - unsigned int sc_sr3; - unsigned int sc_sr5; - unsigned int sc_sr6; - unsigned int sc_sr7; - unsigned int sc_cr0; - unsigned int sc_cr8; - unsigned int sc_cr9; - unsigned int sc_cr10; /* unused */ - unsigned int sc_cr12; - unsigned int sc_cr13; - unsigned int sc_cr24; /* unused */ - unsigned int sc_cr25; /* unused */ - unsigned int sc_cr26; /* unused */ - unsigned sc_mpsfu_high; /* unused */ - unsigned sc_mpsfu_low; /* unused */ - unsigned sc_mpsfu_ovflo; /* unused */ - int sc_pad; - - /* Floating point registers $f0..$f31. */ - double sc_fpregs[32]; - }; - -#endif /* sc_parisc_thread_state */ diff --git a/sysdeps/mach/hurd/hppa/trampoline.c b/sysdeps/mach/hurd/hppa/trampoline.c deleted file mode 100644 index bbb5b960ac..0000000000 --- a/sysdeps/mach/hurd/hppa/trampoline.c +++ /dev/null @@ -1,230 +0,0 @@ -/* Set thread_state for sighandler, and sigcontext to recover. HPPA version. - Copyright (C) 1995, 1997, 1998 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 -#include "thread_state.h" -#include -#include -#include "hurdfault.h" - - -struct mach_msg_trap_regargs - { - /* These first four arguments are in registers 26..23. */ - mach_msg_size_t rcv_size; /* arg3 */ - mach_msg_size_t send_size; /* arg2 */ - mach_msg_option_t option; /* arg1 */ - mach_msg_header_t *msg; /* arg0 */ - }; - -struct sigcontext * -_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, - int signo, long int sigcode, - volatile int rpc_wait, - struct machine_thread_all_state *state) -{ - __label__ trampoline, rpc_wait_trampoline; - void *volatile sigsp; - struct sigcontext *scp; - - if (ss->context) - { - /* We have a previous sigcontext that sigreturn was about - to restore when another signal arrived. We will just base - our setup on that. */ - if (_hurdsig_catch_fault (SIGSEGV)) - assert (_hurdsig_fault_sigcode >= (long int) ss->context && - _hurdsig_fault_sigcode < (long int) (ss->context + 1)); - else - { - memcpy (&state->basic, &ss->context->sc_parisc_thread_state, - sizeof (state->basic)); - state->set = (1 << PARISC_THREAD_STATE); - assert (! rpc_wait); - /* The intr_port slot was cleared before sigreturn sent us the - sig_post that made us notice this pending signal, so - _hurd_internal_post_signal wouldn't do interrupt_operation. - After we return, our caller will set SCP->sc_intr_port (in the - new context) from SS->intr_port and clear SS->intr_port. Now - that we are restoring this old context recorded by sigreturn, - we want to restore its intr_port too; so store it in - SS->intr_port now, so it will end up in SCP->sc_intr_port - later. */ - ss->intr_port = ss->context->sc_intr_port; - } - /* If the sigreturn context was bogus, just ignore it. */ - ss->context = NULL; - } - else if (! machine_get_basic_state (ss->thread, state)) - return NULL; - - if ((ss->actions[signo].sa_flags & SA_ONSTACK) && - !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK))) - { - sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size; - ss->sigaltstack.ss_flags |= SS_ONSTACK; - /* XXX need to set up base of new stack for - per-thread variables, cthreads. */ - } - else - sigsp = (char *) state->basic.uesp; - - /* Push the signal context on the stack. */ - sigsp -= sizeof (*scp); - scp = sigsp; - - if (_hurdsig_catch_fault (SIGSEGV)) - { - assert (_hurdsig_fault_sigcode >= (long int) scp && - _hurdsig_fault_sigcode <= (long int) (scp + 1)); - /* We got a fault trying to write the stack frame. - We cannot set up the signal handler. - Returning NULL tells our caller, who will nuke us with a SIGILL. */ - return NULL; - } - else - { - int ok; - - /* Set up the sigcontext from the current state of the thread. */ - - scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0; - - /* struct sigcontext is laid out so that starting at sc_regs mimics a - struct parisc_thread_state. */ - memcpy (&scp->sc_parisc_thread_state, - &state->basic, sizeof (state->basic)); - - _hurdsig_end_catch_fault (); - - if (! ok) - return NULL; - } - - /* Modify the thread state to call the trampoline code on the new stack. */ - if (rpc_wait) - { - /* The signalee thread was blocked in a mach_msg_trap system call, - still waiting for a reply. We will have it run the special - trampoline code which retries the message receive before running - the signal handler. - - To do this we change the OPTION argument on its stack to enable only - message reception, since the request message has already been - sent. */ - - struct mach_msg_trap_regargs *args = (void *) &state->basic.r23; - - if (_hurdsig_catch_fault (SIGSEGV)) - { - assert (_hurdsig_fault_sigcode >= (long int) args && - _hurdsig_fault_sigcode < (long int) (args + 1)); - /* Faulted accessing ARGS. Bomb. */ - return NULL; - } - - assert (args->option & MACH_RCV_MSG); - /* Disable the message-send, since it has already completed. The - calls we retry need only wait to receive the reply message. */ - args->option &= ~MACH_SEND_MSG; - - /* Limit the time to receive the reply message, in case the server - claimed that `interrupt_operation' succeeded but in fact the RPC - is hung. */ - args->option |= MACH_RCV_TIMEOUT; - args->timeout = _hurd_interrupted_rpc_timeout; - - _hurdsig_end_catch_fault (); - - MACHINE_THREAD_STATE_SET_PC (&state->basic, &&rpc_wait_trampoline); - /* The reply-receiving trampoline code runs initially on the original - user stack. We pass it the signal stack pointer in %r5. */ - state->basic.r5 = (int) sigsp; - /* After doing the message receive, the trampoline code will need to - update the %r28 value to be restored by sigreturn. To simplify - the assembly code, we pass the address of its slot in SCP to the - trampoline code in %r4. */ - state->basic.r4 = (unsigned int) &scp->sc_regs[27]; - /* Set up the arguments for the handler function in callee-saved - registers that we will move to the argument registers after - mach_msg_trap returns. */ - state->basic.r6 = signo; - state->basic.r7 = sigcode; - state->basic.r8 = (unsigned int) scp; - } - else - { - MACHINE_THREAD_STATE_SET_PC (&state->basic, &&trampoline); - state->basic.r20 = (unsigned int) sigsp; - /* Set up the arguments for the handler function. */ - state->basic.r26 = signo; - state->basic.r25 = sigcode; - state->basic.r24 = (unsigned int) scp; - } - - /* We pass the handler function to the trampoline code in %r9. */ - state->basic.r9 = (unsigned int) handler; - /* For convenience, we pass the address of __sigreturn in %r10. */ - state->basic.r10 = (unsigned int) &__sigreturn; - /* The extra copy of SCP for the __sigreturn arg goes in %r8. */ - state->basic.r10 = (unsigned int) scp; - - return scp; - - /* The trampoline code follows. This is not actually executed as part of - this function, it is just convenient to write it that way. */ - - rpc_wait_trampoline: - /* This is the entry point when we have an RPC reply message to receive - before running the handler. The MACH_MSG_SEND bit has already been - cleared in the OPTION argument on our stack. The interrupted user - stack pointer has not been changed, so the system call can find its - arguments; the signal stack pointer is in %ebx. For our convenience, - %ecx points to the sc_eax member of the sigcontext. */ - asm volatile - (/* Retry the interrupted mach_msg system call. */ - "ldil L%0xC0000000,%r1\nble 4(%sr7,%r1)\n" - "ldi -25, %r22\n" /* mach_msg_trap */ - /* When the sigcontext was saved, %r28 was MACH_RCV_INTERRUPTED. But - now the message receive has completed and the original caller of - the RPC (i.e. the code running when the signal arrived) needs to - see the final return value of the message receive in %r28. So - store the new %r28 value into the sc_regs[27] member of the sigcontext - (whose address is in %r4 to make this code simpler). */ - "stw (%r4), %r28\n" - /* Switch to the signal stack. */ - "copy %r5, %r30\n" - /* Copy the handler arguments to the argument registers. */ - "copy %r6, %r26\n" - "copy %r7, %r25\n" - "copy %r8, %r24\n" - ); - - trampoline: - /* Entry point for running the handler normally. The arguments to the - handler function are already in the argument registers. */ - asm volatile - ("bv (%r9); nop" /* Call the handler function. */ - "bv (%r10)\n" /* Call __sigreturn (SCP); never returns. */ - "copy %r8, %r26" /* Set up arg in delay slot. */ - : : "i" (&__sigreturn)); - - /* NOTREACHED */ - return NULL; -} diff --git a/sysdeps/mach/hurd/i386/Dist b/sysdeps/mach/hurd/i386/Dist deleted file mode 100644 index 82c44df00b..0000000000 --- a/sysdeps/mach/hurd/i386/Dist +++ /dev/null @@ -1,3 +0,0 @@ -static-start.S -sys/io.h -ioperm.c diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index caa232026d..f9a7a58deb 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -1,5 +1,6 @@ /* Initialization code run first thing by the ELF startup code. For i386/Hurd. - Copyright (C) 1995,96,97,98,99,2000,01,02,03,04 Free Software Foundation, Inc. + Copyright (C) 1995,96,97,98,99,2000,01,02,03,04,05 + 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,7 +55,7 @@ extern int __libc_argc attribute_hidden; extern char **__libc_argv attribute_hidden; extern char **_dl_argv; -void *(*_cthread_init_routine) (void); /* Returns new SP to use. */ +extern void *(*_cthread_init_routine) (void) __attribute__ ((weak)); void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__)); /* Things that want to be run before _hurd_init or much anything else. @@ -203,7 +204,7 @@ init (int *data) code as the return address, and the argument data immediately above that on the stack. */ - if (_cthread_init_routine) + if (&_cthread_init_routine && _cthread_init_routine) { /* Initialize cthreads, which will allocate us a new stack to run on. */ int *newsp = (*_cthread_init_routine) (); @@ -271,7 +272,7 @@ init (int *data) /* The argument data is just above the stack frame we will unwind by returning. Mutate our own return address to run the code below. */ usercode = data[-1]; - ((void **) data)[-1] = call_init1; + data[-1] = (int) &call_init1; /* Force USERCODE into %eax and &init1 into %ecx, which are not restored by function return. */ asm volatile ("# a %0 c %1" : : "a" (usercode), "c" (&init1)); @@ -319,11 +320,11 @@ first_init (void) stack set up just as the user will see it, so it can switch stacks. */ void -_dl_init_first (int argc, ...) +_dl_init_first (void) { first_init (); - init (&argc); + init ((int *) __builtin_frame_address (0) + 2); } #endif @@ -350,21 +351,23 @@ strong_alias (posixland_init, __libc_init_first); This poorly-named function is called by static-start.S, which should not exist at all. */ void -_hurd_stack_setup (volatile int argc, ...) +_hurd_stack_setup (void) { + intptr_t caller = (intptr_t) __builtin_return_address (0); + void doinit (intptr_t *data) { /* This function gets called with the argument data at TOS. */ - void doinit1 (volatile int argc, ...) + void doinit1 (void) { - init ((int *) &argc); + init ((int *) __builtin_frame_address (0) + 2); } /* Push the user return address after the argument data, and then jump to `doinit1' (above), so it is as if __libc_init_first's caller had called `doinit1' with the argument data already on the stack. */ - *--data = (&argc)[-1]; + *--data = caller; asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ "jmp *%1" : : "r" (data), "r" (&doinit1) : "sp"); @@ -373,7 +376,7 @@ _hurd_stack_setup (volatile int argc, ...) first_init (); - _hurd_startup ((void **) &argc, &doinit); + _hurd_startup ((void **) __builtin_frame_address (0) + 2, &doinit); } #endif diff --git a/sysdeps/mach/hurd/i386/longjmp-ts.c b/sysdeps/mach/hurd/i386/longjmp-ts.c index 586ce6b015..c902002cbc 100644 --- a/sysdeps/mach/hurd/i386/longjmp-ts.c +++ b/sysdeps/mach/hurd/i386/longjmp-ts.c @@ -1,5 +1,5 @@ /* Perform a `longjmp' on a Mach thread_state. i386 version. - Copyright (C) 1991, 1994, 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1991, 1994, 1995, 1997, 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 @@ -19,6 +19,7 @@ #include #include +#include #include diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index ff849716e0..223a47d2f2 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -98,7 +98,7 @@ _hurd_tls_init (tcbhead_t *tcb, int secondcall) { /* Fetch the selector set by the first call. */ int sel; - asm ("mov %%gs, %w0" : "=q" (sel)); + asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); if (__builtin_expect (sel, 0x50) & 4) /* LDT selector */ { error_t err = __i386_set_ldt (tcb->self, sel, &desc, 1); @@ -151,7 +151,7 @@ _hurd_tls_fork (thread_t child, struct i386_thread_state *state) { /* Fetch the selector set by _hurd_tls_init. */ int sel; - asm ("mov %%gs, %w0" : "=q" (sel)); + asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); if (sel == state->ds) /* _hurd_tls_init was never called. */ return 0; diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c index 781a0441dc..dddc6f3ef6 100644 --- a/sysdeps/mach/hurd/i386/trampoline.c +++ b/sysdeps/mach/hurd/i386/trampoline.c @@ -1,5 +1,6 @@ /* Set thread_state for sighandler, and sigcontext to recover. i386 version. - Copyright (C) 1994, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1994,1995,1996,1997,1998,1999,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 @@ -19,11 +20,11 @@ #include #include -#include "thread_state.h" +#include #include #include #include "hurdfault.h" -#include "intr-msg.h" +#include struct sigcontext * diff --git a/sysdeps/mach/hurd/ifreq.c b/sysdeps/mach/hurd/ifreq.c new file mode 100644 index 0000000000..9da8a6803a --- /dev/null +++ b/sysdeps/mach/hurd/ifreq.c @@ -0,0 +1,65 @@ +/* Fetch the host's network interface list. Hurd version. + 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 + 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 +#include +#include +#include + + +void +__ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd) +{ + file_t server; + + server = _hurd_socket_server (PF_INET, 0); + if (server == MACH_PORT_NULL) +