diff --git a/Makerules b/Makerules index 00365bc58b..de43396b34 100644 --- a/Makerules +++ b/Makerules @@ -1016,6 +1016,9 @@ $(inst_libdir)/libc.so: $(common-objpfx)format.lds \ '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\ ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \ ) > $@.new +ifeq ($(patsubst gnu%,,$(config-os)),) + echo 'INPUT ( AS_NEEDED ( -lmachuser -lhurduser ) )' >> $@.new +endif mv -f $@.new $@ endif diff --git a/config.h.in b/config.h.in index 44a34072a4..2f0669e19b 100644 --- a/config.h.in +++ b/config.h.in @@ -159,6 +159,9 @@ /* Mach/i386 specific: define if the `i386_set_gdt' RPC is available. */ #undef HAVE_I386_SET_GDT +/* Hurd specific; define if the `proc_getchildren_rusage' RPC is available. */ +#undef HAVE_HURD_PROC_GETCHILDREN_RUSAGE + /* Define if inlined system calls are available. */ #undef HAVE_INLINED_SYSCALLS diff --git a/htl/Versions b/htl/Versions index 710051756a..02192ad184 100644 --- a/htl/Versions +++ b/htl/Versions @@ -3,6 +3,16 @@ libc { GLIBC_2.12 { pthread_self; __pthread_self; + pthread_attr_getdetachstate; + pthread_attr_getinheritsched; + pthread_attr_getschedparam; + pthread_attr_getschedpolicy; + pthread_attr_setdetachstate; + pthread_attr_setinheritsched; + pthread_attr_setschedpolicy; + pthread_equal; + pthread_getschedparam; + pthread_setschedparam; } GLIBC_2.21 { @@ -38,6 +48,7 @@ libc { __pthread_cleanup_stack; __pthread_total; ___pthread_self; + __pthread_init_thread; } } diff --git a/hurd/Makefile b/hurd/Makefile index 7138e3a6ae..8736d56572 100644 --- a/hurd/Makefile +++ b/hurd/Makefile @@ -29,11 +29,11 @@ inline-headers = hurd.h $(addprefix hurd/,fd.h signal.h \ # The RPC interfaces go in a separate library. interface-library := libhurduser user-interfaces := $(addprefix hurd/,\ - auth startup \ + auth auth_request auth_reply startup \ process process_request \ msg msg_reply msg_request \ - exec exec_startup crash interrupt \ - fs fsys io io_reply io_request \ + exec exec_experimental exec_startup crash interrupt \ + fs fs_experimental fsys io io_reply io_request \ term tioctl socket ifsock \ login password pfinet pci \ ) @@ -56,6 +56,7 @@ routines = hurdstartup hurdinit \ ports-get ports-set hurdports hurdmsg \ errno-loc \ hurdlock \ + sysvshm \ $(sig) $(dtable) $(inlines) \ fd-cleanup port-cleanup report-wait xattr sig = hurdsig hurdfault siginfo hurd-raise preempt-sig \ diff --git a/hurd/Versions b/hurd/Versions index 439e8abf32..d3410232e7 100644 --- a/hurd/Versions +++ b/hurd/Versions @@ -117,6 +117,10 @@ libc { # functions used in macros & inline functions __errno_location; } + GLIBC_2.21 { + # "quasi-internal" functions + _hurd_exec_file_name; + } GLIBC_2.26 { # "quasi-internal" functions _hurd_exec_paths; diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h index 1616c635d5..7bdb4d0ea9 100644 --- a/hurd/hurd/fd.h +++ b/hurd/hurd/fd.h @@ -300,8 +300,6 @@ __hurd_at_flags (int *at_flags, int *flags) *flags &= ~O_NOLINK; *at_flags &= ~AT_SYMLINK_FOLLOW; - if (*at_flags & AT_NO_AUTOMOUNT) - *flags |= O_NOTRANS; *at_flags &= ~AT_NO_AUTOMOUNT; if (*at_flags != 0) diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c index 3178f70075..3da2df83bb 100644 --- a/hurd/hurdexec.c +++ b/hurd/hurdexec.c @@ -25,9 +25,12 @@ #include #include #include +#include #include #include +#include + /* Overlay TASK, executing FILE with arguments ARGV and environment ENVP. If TASK == mach_task_self (), some ports are dealloc'd by the exec server. ARGV and ENVP are terminated by NULL pointers. @@ -39,6 +42,13 @@ _hurd_exec (task_t task, file_t file, return _hurd_exec_paths (task, file, NULL, NULL, argv, envp); } +error_t +__hurd_exec_file_name (task_t task, file_t file, const char *filename, + char *const argv[], char *const envp[]) +{ + return _hurd_exec_paths (task, file, filename, filename, argv, envp); +} + link_warning (_hurd_exec, "_hurd_exec is deprecated, use _hurd_exec_paths instead"); @@ -128,7 +138,6 @@ _hurd_exec_paths (task_t task, file_t file, ss = _hurd_self_sigstate (); retry: - assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); _hurd_sigstate_lock (ss); @@ -442,6 +451,18 @@ retry: portnames, nportnames); /* Fall back for backwards compatibility. This can just be removed when __file_exec goes away. */ + if (err == MIG_BAD_ID) + err = __file_exec_file_name (file, task, flags, + path ? path : "", + args, argslen, env, envlen, + dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize, + ports, MACH_MSG_TYPE_COPY_SEND, + _hurd_nports, + ints, INIT_INT_MAX, + please_dealloc, pdp - please_dealloc, + portnames, nportnames); + /* Fall back for backwards compatibility. This can just be removed + when __file_exec goes away. */ if (err == MIG_BAD_ID) err = __file_exec (file, task, flags, args, argslen, env, envlen, @@ -490,3 +511,9 @@ retry: return err; } libc_hidden_def (_hurd_exec_paths) +extern error_t _hurd_exec_file_name (task_t task, + file_t file, + const char *filename, + char *const argv[], + char *const envp[]); +versioned_symbol (libc, __hurd_exec_file_name, _hurd_exec_file_name, GLIBC_2_21); diff --git a/hurd/hurdlock.c b/hurd/hurdlock.c index 61189094ea..208867659e 100644 --- a/hurd/hurdlock.c +++ b/hurd/hurdlock.c @@ -47,7 +47,7 @@ int __lll_abstimed_wait (void *ptr, int val, const struct timespec *tsp, int flags, int clk) { - if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC) + if (clk != CLOCK_REALTIME) return EINVAL; int mlsec = compute_reltime (tsp, clk); @@ -58,7 +58,7 @@ int __lll_abstimed_wait_intr (void *ptr, int val, const struct timespec *tsp, int flags, int clk) { - if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC) + if (clk != CLOCK_REALTIME) return EINVAL; int mlsec = compute_reltime (tsp, clk); @@ -69,7 +69,7 @@ int __lll_abstimed_xwait (void *ptr, int lo, int hi, const struct timespec *tsp, int flags, int clk) { - if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC) + if (clk != CLOCK_REALTIME) return EINVAL; int mlsec = compute_reltime (tsp, clk); @@ -81,7 +81,7 @@ int __lll_abstimed_lock (void *ptr, const struct timespec *tsp, int flags, int clk) { - if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC) + if (clk != CLOCK_REALTIME) return EINVAL; if (__lll_trylock (ptr) == 0) @@ -167,7 +167,7 @@ __lll_robust_abstimed_lock (void *ptr, int wait_time = 25; unsigned int val; - if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC) + if (clk != CLOCK_REALTIME) return EINVAL; while (1) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 882a03471d..1d732508f4 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -1611,28 +1611,53 @@ _hurdsig_init (const int *intarray, size_t intarraysize) static void reauth_proc (mach_port_t new) { - mach_port_t ref, ignore; + error_t err; + mach_port_t ref, newproc; ref = __mach_reply_port (); - if (! HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], + err = HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], __proc_reauthenticate (port, ref, - MACH_MSG_TYPE_MAKE_SEND) - || __auth_user_authenticate (new, ref, - MACH_MSG_TYPE_MAKE_SEND, - &ignore)) - && ignore != MACH_PORT_NULL) - __mach_port_deallocate (__mach_task_self (), ignore); + MACH_MSG_TYPE_MAKE_SEND)); + if (err) + { + __mach_port_destroy (__mach_task_self (), ref); + return; + } + + err = __auth_user_authenticate (new, ref, + MACH_MSG_TYPE_MAKE_SEND, + &newproc); __mach_port_destroy (__mach_task_self (), ref); + if (err) + return; + + if (newproc == MACH_PORT_NULL) + { + /* Old versions of the proc server did not recreate the process + port when reauthenticating, and passed MACH_PORT_NULL through + the auth server. That must be what we're dealing with. */ + + /* Set the owner of the process here too. */ + __mutex_lock (&_hurd_id.lock); + if (!_hurd_check_ids ()) + HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], + __proc_setowner (port, + (_hurd_id.gen.nuids + ? _hurd_id.gen.uids[0] : 0), + !_hurd_id.gen.nuids)); + __mutex_unlock (&_hurd_id.lock); + + return; + } + + err = __proc_reauthenticate_complete (newproc); + if (err) + { + __mach_port_deallocate (__mach_task_self (), newproc); + return; + } - /* Set the owner of the process here too. */ - __mutex_lock (&_hurd_id.lock); - if (!_hurd_check_ids ()) - HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], - __proc_setowner (port, - (_hurd_id.gen.nuids - ? _hurd_id.gen.uids[0] : 0), - !_hurd_id.gen.nuids)); - __mutex_unlock (&_hurd_id.lock); + _hurd_port_set (&_hurd_ports[INIT_PORT_PROC], newproc); (void) &reauth_proc; /* Silence compiler warning. */ } diff --git a/hurd/sysvshm.c b/hurd/sysvshm.c new file mode 100644 index 0000000000..8557d68d6c --- /dev/null +++ b/hurd/sysvshm.c @@ -0,0 +1,97 @@ +/* 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 +#include +#include +#include +#include +#include + + +/* Description of an shm attachment. */ +struct sysvshm_attach +{ + /* Linked list. */ + struct sysvshm_attach *next; + + /* Map address. */ + void *addr; + + /* Map size. */ + size_t size; +}; + +/* List of attachments. */ +static struct sysvshm_attach *attach_list; + +/* A lock to protect the linked list of shared memory attachments. */ +static unsigned int sysvshm_lock = LLL_LOCK_INITIALIZER; + + +/* Adds a segment attachment. */ +error_t +__sysvshm_add (void *addr, size_t size) +{ + struct sysvshm_attach *shm; + + shm = malloc (sizeof (*shm)); + if (!shm) + return errno; + + __mutex_lock (&sysvshm_lock); + shm->addr = addr; + shm->size = size; + shm->next = attach_list; + attach_list = shm; + __mutex_unlock (&sysvshm_lock); + + return 0; +} + +/* Removes a segment attachment. Returns its size if found, or EINVAL + otherwise. */ +error_t +__sysvshm_remove (void *addr, size_t *size) +{ + struct sysvshm_attach *shm; + struct sysvshm_attach **pshm = &attach_list; + + __mutex_lock (&sysvshm_lock); + shm = attach_list; + while (shm) + { + shm = *pshm; + if (shm->addr == addr) + { + *pshm = shm->next; + *size = shm->size; + __mutex_unlock (&sysvshm_lock); + free (shm); + return 0; + } + pshm = &shm->next; + shm = shm->next; + } + __mutex_unlock (&sysvshm_lock); + return EINVAL; +} diff --git a/hurd/sysvshm.h b/hurd/sysvshm.h new file mode 100644 index 0000000000..1204db8339 --- /dev/null +++ b/hurd/sysvshm.h @@ -0,0 +1,47 @@ +/* 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 + +/* The area (from top to bottom) that is used for private keys. These + are all keys that have the second highest bit set. */ +#define SHM_PRIV_KEY_START INT_MAX +#define SHM_PRIV_KEY_END ((INT_MAX / 2) + 1) + +#define SHM_PREFIX "sysvshm-" +#define SHM_DIR _PATH_DEV "shm/" + +/* The maximum number of characters in a shared memory segment file name. + 32 is the max number of characters in a 128 bit number in hex. */ +#if __WORDSIZE > 128 +#error Need to increase SHM_NAMEMAX. +#else +#define SHM_NAMEMAX (sizeof (SHM_PREFIX) - 1 + 32 + 1) +#endif + +/* Use this with printf and its variants. */ +#define SHM_NAMEPRI SHM_PREFIX "%0x" + + +/* Adds a segment attachment. */ +error_t __sysvshm_add (void *addr, size_t size); + +/* Removes a segment attachment. Returns its size if found, or EINVAL + otherwise. */ +error_t __sysvshm_remove (void *addr, size_t *size); diff --git a/hurd/thread-cancel.c b/hurd/thread-cancel.c index faa923febe..5e3629c97e 100644 --- a/hurd/thread-cancel.c +++ b/hurd/thread-cancel.c @@ -42,7 +42,6 @@ hurd_thread_cancel (thread_t thread) return 0; } - assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); __spin_lock (&ss->lock); err = __thread_suspend (thread); @@ -82,7 +81,6 @@ hurd_check_cancel (void) int cancel; __spin_lock (&ss->lock); - assert (! __spin_lock_locked (&ss->critical_section_lock)); cancel = ss->cancel; ss->cancel = 0; __spin_unlock (&ss->lock); diff --git a/hurd/xattr.c b/hurd/xattr.c index 0715ad7b02..2d83edf2fe 100644 --- a/hurd/xattr.c +++ b/hurd/xattr.c @@ -50,7 +50,15 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) else if (value) { if (*size < sizeof st.st_author) - return ERANGE; + { + if (*size > 0) + return ERANGE; + else + { + *size = sizeof st.st_author; + return 0; + } + } memcpy (value, &st.st_author, sizeof st.st_author); } *size = sizeof st.st_author; @@ -61,15 +69,33 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size) { char *buf = value; mach_msg_type_number_t bufsz = value ? *size : 0; - error_t err = __file_get_translator (port, &buf, &bufsz); + struct stat64 st; + error_t err; + + err = __io_stat (port, &st); + if (err) + return err; + if ((st.st_mode & S_IPTRANS) == 0) + return ENODATA; + + err = __file_get_translator (port, &buf, &bufsz); if (err) return err; - if (value != NULL && *size < bufsz) + + if (*size < bufsz) { if (buf != value) __munmap (buf, bufsz); - return ERANGE; + + if (*size > 0) + return ERANGE; + else + { + *size = bufsz; + return 0; + } } + if (buf != value && bufsz > 0) { if (value != NULL) @@ -149,10 +175,9 @@ _hurd_xattr_set (io_t port, const char *name, const void *value, size_t size, if (err) return err; if (bufsz > 0) - { - __munmap (buf, bufsz); - return ENODATA; - } + __munmap (buf, bufsz); + else + return ENODATA; } return __file_set_translator (port, FS_TRANS_SET | ((flags & XATTR_CREATE) @@ -193,7 +218,7 @@ _hurd_xattr_list (io_t port, void *buffer, size_t *size) if (st.st_mode & S_IPTRANS) add ("gnu.translator"); - if (buffer != NULL && total > *size) + if (*size > 0 && total > *size) return ERANGE; *size = total; return 0; diff --git a/libio/iopopen.c b/libio/iopopen.c index 0bc0fde458..d01cb0648e 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -285,10 +285,9 @@ _IO_new_proc_close (FILE *fp) do { int state; - __libc_ptf_call (__pthread_setcancelstate, - (PTHREAD_CANCEL_DISABLE, &state), 0); + __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); wait_pid = __waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0); - __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); + __pthread_setcancelstate (state, NULL); } while (wait_pid == -1 && errno == EINTR); if (wait_pid == -1) diff --git a/mach/Versions b/mach/Versions index 07fee039fb..72e9d557db 100644 --- a/mach/Versions +++ b/mach/Versions @@ -57,7 +57,6 @@ libc { } GLIBC_2.21 { __mach_host_self_; - mach_print; } GLIBC_2.32 { mach_print; diff --git a/misc/error.c b/misc/error.c index 860b6f5111..e5d5588434 100644 --- a/misc/error.c +++ b/misc/error.c @@ -240,8 +240,7 @@ __error_internal (int status, int errnum, const char *message, /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (__pthread_setcancelstate, - (PTHREAD_CANCEL_DISABLE, &state), 0); + __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); #endif flush_stdout (); @@ -263,7 +262,7 @@ __error_internal (int status, int errnum, const char *message, #ifdef _LIBC _IO_funlockfile (stderr); - __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); + __pthread_setcancelstate (state, NULL); #endif } @@ -307,9 +306,7 @@ __error_at_line_internal (int status, int errnum, const char *file_name, /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (__pthread_setcancelstate, - (PTHREAD_CANCEL_DISABLE, &state), - 0); + __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); #endif flush_stdout (); @@ -339,7 +336,7 @@ __error_at_line_internal (int status, int errnum, const char *file_name, #ifdef _LIBC _IO_funlockfile (stderr); - __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); + __pthread_setcancelstate (state, NULL); #endif } diff --git a/misc/getauxval.c b/misc/getauxval.c index 629402083c..8757c67fc3 100644 --- a/misc/getauxval.c +++ b/misc/getauxval.c @@ -19,7 +19,6 @@ #include #include #include -#include bool __getauxval2 (unsigned long int type, unsigned long int *result) @@ -28,14 +27,6 @@ __getauxval2 (unsigned long int type, unsigned long int *result) ElfW(auxv_t) *p; #endif -#ifdef AT_SECURE - if (type == AT_SECURE) - { - *result = __libc_enable_secure; - return true; - } -#endif - if (type == AT_HWCAP) { *result = GLRO(dl_hwcap); diff --git a/misc/getttyent.c b/misc/getttyent.c index 508d296291..92d92b026f 100644 --- a/misc/getttyent.c +++ b/misc/getttyent.c @@ -66,7 +66,7 @@ __getttyent (void) static struct ttyent tty; int c; char *p; -#define MAXLINELENGTH 512 +#define MAXLINELENGTH 100 static char line[MAXLINELENGTH]; if (!tf && !__setttyent()) diff --git a/misc/madvise.c b/misc/madvise.c index 7cdeb4111e..f91790ced3 100644 --- a/misc/madvise.c +++ b/misc/madvise.c @@ -32,4 +32,4 @@ __madvise (void *addr, size_t len, int advice) libc_hidden_def (__madvise) weak_alias (__madvise, madvise) -stub_warning (madvise) +/* stub_warning (madvise) */ diff --git a/posix/posix_madvise.c b/posix/posix_madvise.c index 4c44595a5d..7b8252afe9 100644 --- a/posix/posix_madvise.c +++ b/posix/posix_madvise.c @@ -27,4 +27,4 @@ posix_madvise (void *addr, size_t len, int advice) { return ENOSYS; } -stub_warning (posix_madvise) +/* stub_warning (posix_madvise) */ diff --git a/rt/timer_create.c b/rt/timer_create.c index a9f0c13bbd..15e542dcce 100644 --- a/rt/timer_create.c +++ b/rt/timer_create.c @@ -47,7 +47,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) return -1; } - if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE) + if (clock_id != CLOCK_REALTIME) { __set_errno (EINVAL); return -1; diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c index 1c048c23b5..1eaf63c752 100644 --- a/stdlib/fmtmsg.c +++ b/stdlib/fmtmsg.c @@ -124,8 +124,7 @@ fmtmsg (long int classification, const char *label, int severity, /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (__pthread_setcancelstate, - (PTHREAD_CANCEL_DISABLE, &state), 0); + __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); __libc_lock_lock (lock); @@ -194,7 +193,7 @@ fmtmsg (long int classification, const char *label, int severity, __libc_lock_unlock (lock); - __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); + __pthread_setcancelstate (state, NULL); return result; } diff --git a/sysdeps/generic/paths.h b/sysdeps/generic/paths.h index 893b4c2286..6b8f440428 100644 --- a/sysdeps/generic/paths.h +++ b/sysdeps/generic/paths.h @@ -51,7 +51,7 @@ #define _PATH_MAN "/usr/share/man" #define _PATH_MEM "/dev/mem" #define _PATH_MNTTAB "/etc/fstab" -#define _PATH_MOUNTED "/var/run/mtab" +#define _PATH_MOUNTED "/etc/mtab" #define _PATH_NOLOGIN "/etc/nologin" #define _PATH_PRESERVE "/var/lib" #define _PATH_RWHODIR "/var/spool/rwho" diff --git a/sysdeps/htl/pt-attr-getdetachstate.c b/sysdeps/htl/pt-attr-getdetachstate.c index 8b077e38f3..da27398260 100644 --- a/sysdeps/htl/pt-attr-getdetachstate.c +++ b/sysdeps/htl/pt-attr-getdetachstate.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -26,4 +27,8 @@ __pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) return 0; } -weak_alias (__pthread_attr_getdetachstate, pthread_attr_getdetachstate); +versioned_symbol (libc, __pthread_attr_getdetachstate, pthread_attr_getdetachstate, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_getdetachstate, pthread_attr_getdetachstate, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-attr-getinheritsched.c b/sysdeps/htl/pt-attr-getinheritsched.c index 078face3eb..ba02e202c3 100644 --- a/sysdeps/htl/pt-attr-getinheritsched.c +++ b/sysdeps/htl/pt-attr-getinheritsched.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -26,4 +27,8 @@ __pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inheritsched) return 0; } -weak_alias (__pthread_attr_getinheritsched, pthread_attr_getinheritsched); +versioned_symbol (libc, __pthread_attr_getinheritsched, pthread_attr_getinheritsched, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_getinheritsched, pthread_attr_getinheritsched, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-attr-getschedparam.c b/sysdeps/htl/pt-attr-getschedparam.c index 3fa001871e..35eeedc442 100644 --- a/sysdeps/htl/pt-attr-getschedparam.c +++ b/sysdeps/htl/pt-attr-getschedparam.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -30,4 +31,8 @@ __pthread_attr_getschedparam (const pthread_attr_t *attr, return 0; } -weak_alias (__pthread_attr_getschedparam, pthread_attr_getschedparam); +versioned_symbol (libc, __pthread_attr_getschedparam, pthread_attr_getschedparam, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_getschedparam, pthread_attr_getschedparam, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-attr-getschedpolicy.c b/sysdeps/htl/pt-attr-getschedpolicy.c index 8b4cc7ce48..5deaf01c5e 100644 --- a/sysdeps/htl/pt-attr-getschedpolicy.c +++ b/sysdeps/htl/pt-attr-getschedpolicy.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -26,4 +27,8 @@ __pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) return 0; } -weak_alias (__pthread_attr_getschedpolicy, pthread_attr_getschedpolicy); +versioned_symbol (libc, __pthread_attr_getschedpolicy, pthread_attr_getschedpolicy, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_getschedpolicy, pthread_attr_getschedpolicy, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-attr-setdetachstate.c b/sysdeps/htl/pt-attr-setdetachstate.c index b40557f816..26b6f91dc6 100644 --- a/sysdeps/htl/pt-attr-setdetachstate.c +++ b/sysdeps/htl/pt-attr-setdetachstate.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -35,4 +36,8 @@ __pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) return 0; } -weak_alias (__pthread_attr_setdetachstate, pthread_attr_setdetachstate); +versioned_symbol (libc, __pthread_attr_setdetachstate, pthread_attr_setdetachstate, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_setdetachstate, pthread_attr_setdetachstate, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-attr-setinheritsched.c b/sysdeps/htl/pt-attr-setinheritsched.c index 533b805b12..4ad0bb1dec 100644 --- a/sysdeps/htl/pt-attr-setinheritsched.c +++ b/sysdeps/htl/pt-attr-setinheritsched.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -35,4 +36,8 @@ __pthread_attr_setinheritsched (pthread_attr_t *attr, int inheritsched) return 0; } -weak_alias (__pthread_attr_setinheritsched, pthread_attr_setinheritsched); +versioned_symbol (libc, __pthread_attr_setinheritsched, pthread_attr_setinheritsched, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_setinheritsched, pthread_attr_setinheritsched, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-attr-setschedpolicy.c b/sysdeps/htl/pt-attr-setschedpolicy.c index d8086e8316..9648c774d0 100644 --- a/sysdeps/htl/pt-attr-setschedpolicy.c +++ b/sysdeps/htl/pt-attr-setschedpolicy.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -39,4 +40,8 @@ __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) return 0; } -weak_alias (__pthread_attr_setschedpolicy, pthread_attr_setschedpolicy); +versioned_symbol (libc, __pthread_attr_setschedpolicy, pthread_attr_setschedpolicy, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_attr_setschedpolicy, pthread_attr_setschedpolicy, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-equal.c b/sysdeps/htl/pt-equal.c index 6411110608..7727cca370 100644 --- a/sysdeps/htl/pt-equal.c +++ b/sysdeps/htl/pt-equal.c @@ -17,6 +17,7 @@ . */ #include +#include #include /* Return true if __T1 and __T2 both name the same thread. Otherwise, @@ -27,4 +28,8 @@ __pthread_equal (pthread_t __t1, pthread_t __t2) return __t1 == __t2; } -weak_alias (__pthread_equal, pthread_equal); +versioned_symbol (libc, __pthread_equal, pthread_equal, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_equal, pthread_equal, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-getschedparam.c b/sysdeps/htl/pt-getschedparam.c index 8ec3d54bd4..0c6a2d0ab3 100644 --- a/sysdeps/htl/pt-getschedparam.c +++ b/sysdeps/htl/pt-getschedparam.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -28,4 +29,8 @@ __pthread_getschedparam (pthread_t thread, int *policy, return 0; } -weak_alias (__pthread_getschedparam, pthread_getschedparam); +versioned_symbol (libc, __pthread_getschedparam, pthread_getschedparam, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_getschedparam, pthread_getschedparam, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/pt-setschedparam.c b/sysdeps/htl/pt-setschedparam.c index aea4e7b0e4..5594c9f390 100644 --- a/sysdeps/htl/pt-setschedparam.c +++ b/sysdeps/htl/pt-setschedparam.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -26,5 +27,9 @@ __pthread_setschedparam (pthread_t thread, int policy, return ENOSYS; } -weak_alias (__pthread_setschedparam, pthread_setschedparam); +versioned_symbol (libc, __pthread_setschedparam, pthread_setschedparam, GLIBC_2_21); stub_warning (pthread_setschedparam) + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_setschedparam, pthread_setschedparam, GLIBC_2_12); +#endif diff --git a/sysdeps/mach/Makefile b/sysdeps/mach/Makefile index 7ee71af759..fb8472ebba 100644 --- a/sysdeps/mach/Makefile +++ b/sysdeps/mach/Makefile @@ -35,7 +35,7 @@ endif # because it's different in Darwin and the conditional crap is # too much trouble. This should suffice for getting the mach/Makefile # rules invoked when they need to be. -mach-before-compile := $(mach-objpfx)mach-shortcuts.h \ +mach-before-compile := $(mach-objpfx)mach-shortcuts.h $(mach-objpfx)mach/mach_interface.h \ $(patsubst %,$(mach-objpfx)mach/mach_%.h,\ port host) diff --git a/sysdeps/mach/clock_gettime.c b/sysdeps/mach/clock_gettime.c index a489a68491..6fffad39f5 100644 --- a/sysdeps/mach/clock_gettime.c +++ b/sysdeps/mach/clock_gettime.c @@ -32,10 +32,6 @@ __clock_gettime (clockid_t clock_id, struct timespec *ts) switch (clock_id) { case CLOCK_REALTIME: - case CLOCK_MONOTONIC: - case CLOCK_MONOTONIC_RAW: - case CLOCK_REALTIME_COARSE: - case CLOCK_MONOTONIC_COARSE: { /* __host_get_time can only fail if passed an invalid host_t. __mach_host_self could theoretically fail (producing an diff --git a/sysdeps/mach/clock_nanosleep.c b/sysdeps/mach/clock_nanosleep.c index 34d6a362d7..6c6b4d8d42 100644 --- a/sysdeps/mach/clock_nanosleep.c +++ b/sysdeps/mach/clock_nanosleep.c @@ -67,7 +67,7 @@ int __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, struct timespec *rem) { - if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE) + if (clock_id != CLOCK_REALTIME || !valid_nanoseconds (req->tv_nsec) || (flags != 0 && flags != TIMER_ABSTIME)) return EINVAL; diff --git a/sysdeps/mach/hurd/bind.c b/sysdeps/mach/hurd/bind.c index c492c7c5c7..689059fa6e 100644 --- a/sysdeps/mach/hurd/bind.c +++ b/sysdeps/mach/hurd/bind.c @@ -48,7 +48,7 @@ __bind (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len) return -1; /* Create a new, unlinked node in the target directory. */ - err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node); + err = __dir_mkfile (dir, O_CREAT, 0666, &node); if (! err) { @@ -76,11 +76,16 @@ __bind (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len) err = EGRATUITOUS; if (! err) { - /* Link the node, now a socket with proper mode, into the - target directory. */ - err = __dir_link (dir, node, n, 1); - if (err == EEXIST) - err = EADDRINUSE; + /* Fix the access mode before showing the file. */ + err = __file_chmod (node, 0666 & ~_hurd_umask); + if (! err) + { + /* Link the node, now a socket with proper mode, into the + target directory. */ + err = __dir_link (dir, node, n, 1); + if (err == EEXIST) + err = EADDRINUSE; + } if (err) __mach_port_deallocate (__mach_task_self (), aport); } diff --git a/sysdeps/mach/hurd/bits/errno.h b/sysdeps/mach/hurd/bits/errno.h index 3b54f5855e..eb5943f9c2 100644 --- a/sysdeps/mach/hurd/bits/errno.h +++ b/sysdeps/mach/hurd/bits/errno.h @@ -112,7 +112,9 @@ enum __error_t_codes EILSEQ = 0x4000006a, /* Invalid or incomplete multibyte or wide character */ EBACKGROUND = 0x40000064, /* Inappropriate operation for background process */ EDIED = 0x40000065, /* Translator died */ +#if 0 ED = 0x40000066, /* ? */ +#endif EGREGIOUS = 0x40000067, /* You really blew it this time */ EIEIO = 0x40000068, /* Computer bought the farm */ EGRATUITOUS = 0x40000069, /* Gratuitous error */ @@ -310,7 +312,9 @@ enum __error_t_codes #define EILSEQ 0x4000006a #define EBACKGROUND 0x40000064 #define EDIED 0x40000065 +#if 0 #define ED 0x40000066 +#endif #define EGREGIOUS 0x40000067 #define EIEIO 0x40000068 #define EGRATUITOUS 0x40000069 diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h index a5716f127e..5b94528352 100644 --- a/sysdeps/mach/hurd/bits/ioctls.h +++ b/sysdeps/mach/hurd/bits/ioctls.h @@ -274,11 +274,13 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define FIOSETOWN _IOW('f', 124, int) /* set owner */ #define FIOGETOWN _IOR('f', 123, int) /* get owner */ +#if 0 /* socket i/o controls */ #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ +#endif #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ #define SIOCSPGRP _IOW('s', 8, int) /* set process group */ #define SIOCGPGRP _IOR('s', 9, int) /* get process group */ @@ -306,12 +308,16 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) /* get IF metric */ #define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) /* set IF metric */ #define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */ +#if 0 #define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */ +#endif +#if 0 #define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */ #define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */ #define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */ #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */ +#endif #define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int)/* get IF mtu */ #define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) /* set IF mtu */ @@ -333,7 +339,9 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; # define OTIOCGETD _IOR('t', 0, int) /* get line discipline */ # define OTIOCSETD _IOW('t', 1, int) /* set line discipline */ #endif +#if 0 #define TIOCHPCL _IO('t', 2) /* hang up on last close */ +#endif #define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */ #define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */ #define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/ @@ -386,6 +394,7 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define PENDIN 0x20000000 /* tp->t_rawq needs reread */ #define DECCTQ 0x40000000 /* only ^Q starts after ^S */ #define NOFLSH 0x80000000 /* no output flush on signal */ +#if 0 #define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */ #define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */ #define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */ @@ -411,6 +420,7 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define OTTYDISC 0 #define NETLDISC 1 #define NTTYDISC 2 +#endif /* From 4.4 . */ #ifdef USE_OLD_TTY diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h index f0a2cb6fd9..5b4f8f7885 100644 --- a/sysdeps/mach/hurd/bits/posix_opt.h +++ b/sysdeps/mach/hurd/bits/posix_opt.h @@ -68,8 +68,8 @@ /* X/Open thread realtime support is not supported. */ #undef _XOPEN_REALTIME_THREADS -/* XPG4.2 shared memory is not supported. */ -#undef _XOPEN_SHM +/* XPG4.2 shared memory is supported. */ +#define _XOPEN_SHM 1 /* Tell we have POSIX threads. */ #define _POSIX_THREADS 200809L @@ -163,10 +163,10 @@ #define _POSIX_THREAD_PROCESS_SHARED -1 /* The monotonic clock might be available. */ -#define _POSIX_MONOTONIC_CLOCK 200809L +#define _POSIX_MONOTONIC_CLOCK 0 -/* The clock selection interfaces are not really available yet. */ -#define _POSIX_CLOCK_SELECTION -1 +/* The clock selection interfaces are available. */ +#define _POSIX_CLOCK_SELECTION 200809L /* Advisory information interfaces could be available in future. */ #define _POSIX_ADVISORY_INFO 0 diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure index 33d3e1fc0f..855fd7762a 100644 --- a/sysdeps/mach/hurd/configure +++ b/sysdeps/mach/hurd/configure @@ -45,6 +45,180 @@ if test "x$libc_cv_hurd_version" != xok; then as_fn_error $? "Hurd headers not installed or too old" "$LINENO" 5 fi + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +printf %s "checking for grep that handles long lines and -e... " >&6; } +if test ${ac_cv_path_GREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in grep ggrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +printf "%s\n" "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +printf %s "checking for egrep... " >&6; } +if test ${ac_cv_path_EGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in egrep + do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + printf %s 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + printf "%s\n" 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +printf "%s\n" "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for proc_getchildren_rusage in process.defs" >&5 +printf %s "checking for proc_getchildren_rusage in process.defs... " >&6; } +if test ${libc_cv_hurd_rpc_proc_getchildren_rusage+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "proc_getchildren_rusage" >/dev/null 2>&1 +then : + libc_cv_hurd_rpc_proc_getchildren_rusage=yes +else $as_nop + libc_cv_hurd_rpc_proc_getchildren_rusage=no +fi +rm -rf conftest* + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hurd_rpc_proc_getchildren_rusage" >&5 +printf "%s\n" "$libc_cv_hurd_rpc_proc_getchildren_rusage" >&6; } +if test $libc_cv_hurd_rpc_proc_getchildren_rusage = yes; then + printf "%s\n" "#define HAVE_HURD_PROC_GETCHILDREN_RUSAGE 1" >>confdefs.h + +fi + + if test -n "$sysheaders"; then CPPFLAGS=$OLD_CPPFLAGS fi @@ -52,3 +226,4 @@ fi # Hurd has libpthread as a separate library. pthread_in_libc=no +use_ldconfig=yes diff --git a/sysdeps/mach/hurd/configure.ac b/sysdeps/mach/hurd/configure.ac index 82d085af33..a348cde625 100644 --- a/sysdeps/mach/hurd/configure.ac +++ b/sysdeps/mach/hurd/configure.ac @@ -23,9 +23,30 @@ if test "x$libc_cv_hurd_version" != xok; then AC_MSG_ERROR(Hurd headers not installed or too old) fi +dnl +dnl hurd_RPC_CHECK(interface.defs, rpc_method, define) +dnl +dnl Check if rpc_method RPC is defined by interface.defs +dnl and define `define`. +dnl +AC_DEFUN([hurd_RPC_CHECK], [dnl +AC_CACHE_CHECK(for $2 in $1, libc_cv_hurd_rpc_$2, [dnl +AC_EGREP_HEADER($2, hurd/$1, + libc_cv_hurd_rpc_$2=yes, + libc_cv_hurd_rpc_$2=no)]) +if test $libc_cv_hurd_rpc_$2 = yes; then + AC_DEFINE([$3]) +fi +]) + +hurd_RPC_CHECK(process.defs, proc_getchildren_rusage, + HAVE_HURD_PROC_GETCHILDREN_RUSAGE) + if test -n "$sysheaders"; then CPPFLAGS=$OLD_CPPFLAGS fi # Hurd has libpthread as a separate library. pthread_in_libc=no + +use_ldconfig=yes diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 43129a1e74..6e2013f51d 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -66,6 +66,8 @@ void *_dl_random attribute_relro = NULL; struct hurd_startup_data *_dl_hurd_data; +uintptr_t __stack_chk_guard attribute_relro; + ElfW(Addr) _dl_sysdep_start (void **start_argptr, diff --git a/sysdeps/mach/hurd/ftok.c b/sysdeps/mach/hurd/ftok.c new file mode 100644 index 0000000000..4ca1daf55c --- /dev/null +++ b/sysdeps/mach/hurd/ftok.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1995, 1996, 2000, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , August 1995. + + 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 + + +/* In the Hurd, we use the second-to-most-significant bit as flag for + private keys. We use a different order of the components so that + the biggest one---the inode number---is affected by this. */ + +key_t +ftok (const char *pathname, int proj_id) +{ + struct stat64 st; + key_t key; + + if (__stat64 (pathname, &st) < 0) + return (key_t) -1; + + key = ((st.st_dev & 0xff) | ((proj_id & 0xff) << 8) + | ((st.st_ino & 0x3fff) << 16)); + + return key; +} diff --git a/sysdeps/mach/hurd/getrusage.c b/sysdeps/mach/hurd/getrusage.c index 7be4dd1793..8151c297e1 100644 --- a/sysdeps/mach/hurd/getrusage.c +++ b/sysdeps/mach/hurd/getrusage.c @@ -75,9 +75,13 @@ __getrusage (enum __rusage_who who, struct rusage *usage) break; case RUSAGE_CHILDREN: - /* XXX Not implemented yet. However, zero out USAGE to be - consistent with the wait3 and wait4 functions. */ +#ifdef HAVE_HURD_PROC_GETCHILDREN_RUSAGE + err = __USEPORT (PROC, __proc_getchildren_rusage (port, usage)); + if (err) + return __hurd_fail (err); +#else memset (usage, 0, sizeof (struct rusage)); +#endif break; diff --git a/sysdeps/mach/hurd/htl/pt-pthread_self.c b/sysdeps/mach/hurd/htl/pt-pthread_self.c index 04fa283aab..d11d0ec676 100644 --- a/sysdeps/mach/hurd/htl/pt-pthread_self.c +++ b/sysdeps/mach/hurd/htl/pt-pthread_self.c @@ -17,6 +17,14 @@ . */ #include +#include -__thread struct __pthread *___pthread_self; +/* Initial thread structure used before libpthread is initialized, so various + * functions can already work at least basically. */ +struct __pthread __pthread_init_thread = { + .thread = 1, +}; +libc_hidden_def (__pthread_init_thread) + +__thread struct __pthread *___pthread_self = &__pthread_init_thread; libc_hidden_tls_def (___pthread_self) diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.c b/sysdeps/mach/hurd/htl/pt-sysdep.c index 270e77531e..73b13823bb 100644 --- a/sysdeps/mach/hurd/htl/pt-sysdep.c +++ b/sysdeps/mach/hurd/htl/pt-sysdep.c @@ -26,10 +26,6 @@ #include #include -/* Initial thread structure used temporarily during initialization, so various - * functions can already work at least basically. */ -static struct __pthread init_thread; - static void reset_pthread_total (void) { @@ -51,10 +47,6 @@ _init_routine (void *stack) /* Already initialized */ return; - /* Initialize early thread structure. */ - init_thread.thread = 1; - ___pthread_self = &init_thread; - /* Initialize the library. */ ___pthread_init (); @@ -107,9 +99,9 @@ _init_routine (void *stack) #endif /* Copy over the thread-specific state */ - assert (!init_thread.thread_specifics); + assert (!__pthread_init_thread.thread_specifics); memcpy (&thread->static_thread_specifics, - &init_thread.static_thread_specifics, + &__pthread_init_thread.static_thread_specifics, sizeof (thread->static_thread_specifics)); ___pthread_self = thread; diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.h b/sysdeps/mach/hurd/htl/pt-sysdep.h index 09d9547a8e..8e94395be7 100644 --- a/sysdeps/mach/hurd/htl/pt-sysdep.h +++ b/sysdeps/mach/hurd/htl/pt-sysdep.h @@ -34,6 +34,8 @@ extern __thread struct __pthread *___pthread_self; libc_hidden_tls_proto (___pthread_self) +extern struct __pthread __pthread_init_thread; +libc_hidden_proto (__pthread_init_thread) #ifdef DEBUG #define _pthread_self() \ diff --git a/sysdeps/mach/hurd/i386/ld.abilist b/sysdeps/mach/hurd/i386/ld.abilist index ebba31f770..bba7078aa0 100644 --- a/sysdeps/mach/hurd/i386/ld.abilist +++ b/sysdeps/mach/hurd/i386/ld.abilist @@ -17,3 +17,4 @@ GLIBC_2.2.6 abort F GLIBC_2.3 ___tls_get_addr F GLIBC_2.3 __tls_get_addr F GLIBC_2.34 __rtld_version_placeholder F +GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 39744f633e..bb25691747 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -29,7 +29,17 @@ GLIBC_2.11 mkostemps64 F GLIBC_2.11 mkstemps F GLIBC_2.11 mkstemps64 F GLIBC_2.12 __pthread_self F +GLIBC_2.12 pthread_attr_getdetachstate F +GLIBC_2.12 pthread_attr_getinheritsched F +GLIBC_2.12 pthread_attr_getschedparam F +GLIBC_2.12 pthread_attr_getschedpolicy F +GLIBC_2.12 pthread_attr_setdetachstate F +GLIBC_2.12 pthread_attr_setinheritsched F +GLIBC_2.12 pthread_attr_setschedpolicy F +GLIBC_2.12 pthread_equal F +GLIBC_2.12 pthread_getschedparam F GLIBC_2.12 pthread_self F +GLIBC_2.12 pthread_setschedparam F GLIBC_2.13 __fentry__ F GLIBC_2.14 syncfs F GLIBC_2.15 __fdelt_chk F @@ -341,7 +351,6 @@ GLIBC_2.2.6 __mach_msg_destroy F GLIBC_2.2.6 __mach_port_allocate F GLIBC_2.2.6 __mach_port_deallocate F GLIBC_2.2.6 __mach_port_insert_right F -GLIBC_2.21 __mach_print F GLIBC_2.2.6 __mach_reply_port F GLIBC_2.2.6 __mach_task_self_ D 0x4 GLIBC_2.2.6 __mach_thread_self F @@ -610,7 +619,7 @@ GLIBC_2.2.6 _libc_intl_domainname D 0x5 GLIBC_2.2.6 _longjmp F GLIBC_2.2.6 _mcleanup F GLIBC_2.2.6 _mcount F -GLIBC_2.2.6 _nl_default_dirname D 0xe +GLIBC_2.2.6 _nl_default_dirname D 0x12 GLIBC_2.2.6 _nl_domain_bindings D 0x4 GLIBC_2.2.6 _nl_msg_cat_cntr D 0x4 GLIBC_2.2.6 _null_auth D 0xc @@ -1976,6 +1985,7 @@ GLIBC_2.2.6 xprt_register F GLIBC_2.2.6 xprt_unregister F GLIBC_2.21 __mach_host_self_ D 0x4 GLIBC_2.21 __pthread_get_cleanup_stack F +GLIBC_2.21 _hurd_exec_file_name F GLIBC_2.21 pthread_attr_destroy F GLIBC_2.21 pthread_attr_getdetachstate F GLIBC_2.21 pthread_attr_getinheritsched F diff --git a/sysdeps/mach/hurd/ifaddrs.c b/sysdeps/mach/hurd/ifaddrs.c new file mode 100644 index 0000000000..dfb7a304e0 --- /dev/null +++ b/sysdeps/mach/hurd/ifaddrs.c @@ -0,0 +1,310 @@ +/* getifaddrs -- get names and addresses of all network interfaces + Copyright (C) 2013-2015 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 +#include +#include +#include +#include +#include +#include +#include + +/* Create a linked list of `struct ifaddrs' structures, one for each + network interface on the host machine. If successful, store the + list in *IFAP and return 0. On errors, return -1 and set `errno'. */ +int +__getifaddrs (struct ifaddrs **ifap) +{ + /* XXX: Hackish. This assumes pfinet parameter style, and that the same + pfinet is on /servers/socket/2 and /servers/socket/26. + + To be replaced by something like a netlink protocol, or fix ifreq into + using sockaddr_storage (but break existing compiled programs using it). */ + + file_t node; + char *argz = 0, *cur; + mach_msg_type_number_t argz_len = 0; + unsigned naddrs; + const char *ifa_name = NULL; + char *addr, *cidr_a; + int cidr; + + node = __file_name_lookup (_SERVERS_SOCKET "/2", 0, 0666); + + if (node == MACH_PORT_NULL) + return -1; + + __file_get_fs_options (node, &argz, &argz_len); + + __mach_port_deallocate (__mach_task_self (), node); + + /* XXX: Two hardcoded for lo */ + naddrs = 2; + + for (cur = argz; cur < argz + argz_len; cur = cur + strlen (cur) + 1) + { + if (!strncmp (cur, "--address=", 10)) + naddrs++; + else if (!strncmp (cur, "--address6=", 11)) + naddrs++; + } + + { + struct + { + struct ifaddrs ia; + struct sockaddr_storage addr, netmask, broadaddr; + char name[IF_NAMESIZE]; + } *storage; + int i; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + + storage = malloc (naddrs * sizeof storage[0]); + if (storage == NULL) + { + __munmap (argz, argz_len); + return -1; + } + + i = 0; + + /* XXX: Hardcoded lo interface */ + ifa_name = "lo"; + + /* 127.0.0.1/8 */ + storage[i].ia.ifa_next = &storage[i + 1].ia; + storage[i].ia.ifa_name = strncpy (storage[i].name, ifa_name, sizeof (storage[i].name)); + + storage[i].ia.ifa_addr = (struct sockaddr *) &storage[i].addr; + sin = ((struct sockaddr_in *) &storage[i].addr); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_port = 0; + sin->sin_addr.s_addr = htonl (INADDR_LOOPBACK); + + storage[i].ia.ifa_netmask = (struct sockaddr *) &storage[i].netmask; + sin = ((struct sockaddr_in *) &storage[i].netmask); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_port = 0; + sin->sin_addr.s_addr = htonl (IN_CLASSA_NET); + + storage[i].ia.ifa_broadaddr = (struct sockaddr *) &storage[i].addr; + + storage[i].ia.ifa_flags = IFF_UP | IFF_LOOPBACK | IFF_RUNNING; + + storage[i].ia.ifa_data = NULL; /* Nothing here for now. */ + + i++; + + /* ::1/128 */ + storage[i].ia.ifa_next = &storage[i + 1].ia; + storage[i].ia.ifa_name = strncpy (storage[i].name, ifa_name, sizeof (storage[i].name)); + + storage[i].ia.ifa_addr = (struct sockaddr *) &storage[i].addr; + sin6 = ((struct sockaddr_in6 *) &storage[i].addr); + sin6->sin6_family = AF_INET6; + sin6->sin6_len = sizeof(*sin6); + sin6->sin6_port = 0; + sin6->sin6_flowinfo = 0; + inet_pton (AF_INET6, "::1", &sin6->sin6_addr); + sin6->sin6_scope_id = 0; + + storage[i].ia.ifa_netmask = (struct sockaddr *) &storage[i].netmask; + sin6 = ((struct sockaddr_in6 *) &storage[i].netmask); + sin6->sin6_family = AF_INET6; + sin6->sin6_len = sizeof(*sin6); + sin6->sin6_port = 0; + sin6->sin6_flowinfo = 0; + inet_pton (AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", &sin6->sin6_addr); + sin6->sin6_scope_id = 0; + + storage[i].ia.ifa_broadaddr = NULL; + + storage[i].ia.ifa_flags = IFF_UP | IFF_LOOPBACK | IFF_RUNNING; + + storage[i].ia.ifa_data = NULL; /* Nothing here for now. */ + + for (cur = argz; cur < argz + argz_len; cur = cur + strlen (cur) + 1) + { + if (!strncmp (cur, "--interface=", 12)) + { + ifa_name = cur + 12; + continue; + } + + else if (!strncmp (cur, "--address=", 10)) + { + i++; + /* IPv4 address */ + addr = cur + 10; + + storage[i].ia.ifa_next = &storage[i + 1].ia; + storage[i].ia.ifa_name = strncpy (storage[i].name, ifa_name, sizeof (storage[i].name)); + + storage[i].ia.ifa_addr = (struct sockaddr *) &storage[i].addr; + sin = ((struct sockaddr_in *) &storage[i].addr); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_port = 0; + inet_pton (AF_INET, addr, &sin->sin_addr); + + storage[i].ia.ifa_netmask = NULL; + storage[i].ia.ifa_broadaddr = NULL; + + storage[i].ia.ifa_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_MULTICAST; + storage[i].ia.ifa_data = NULL; /* Nothing here for now. */ + } + + else if (!strncmp (cur, "--netmask=", 10)) + { + /* IPv4 netmask */ + addr = cur + 10; + + storage[i].ia.ifa_netmask = (struct sockaddr *) &storage[i].netmask; + sin = ((struct sockaddr_in *) &storage[i].netmask); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_port = 0; + inet_pton (AF_INET, addr, &sin->sin_addr); + + storage[i].ia.ifa_broadaddr = (struct sockaddr *) &storage[i].broadaddr; + sin = ((struct sockaddr_in *) &storage[i].broadaddr); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_port = 0; + sin->sin_addr.s_addr = + ((struct sockaddr_in *) &storage[i].addr)->sin_addr.s_addr + | ~(((struct sockaddr_in *) &storage[i].netmask)->sin_addr.s_addr); + } + + else if (!strncmp (cur, "--peer=", 7)) + { + /* IPv4 peer */ + addr = cur + 7; + + storage[i].ia.ifa_dstaddr = (struct sockaddr *) &storage[i].broadaddr; + sin = ((struct sockaddr_in *) &storage[i].broadaddr); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_port = 0; + inet_pton (AF_INET, addr, &sin->sin_addr); + + storage[i].ia.ifa_flags &= ~IFF_BROADCAST; + storage[i].ia.ifa_flags |= IFF_POINTOPOINT; + } + + else if (!strncmp (cur, "--address6=", 11)) + { + i++; + /* IPv6 address */ + addr = cur + 11; + cidr_a = strchr (addr, '/'); + if (!cidr_a) + { + /* No CIDR length?! Assume 64. */ + addr = __strdup (addr); + cidr = 64; + } + else + { + addr = __strndup (addr, cidr_a - addr); + cidr = atoi (cidr_a + 1); + } + + storage[i].ia.ifa_next = &storage[i + 1].ia; + storage[i].ia.ifa_name = strncpy (storage[i].name, ifa_name, sizeof (storage[i].name)); + + storage[i].ia.ifa_addr = (struct sockaddr *) &storage[i].addr; + sin6 = ((struct sockaddr_in6 *) &storage[i].addr); + sin6->sin6_family = AF_INET6; + sin6->sin6_len = sizeof(*sin6); + sin6->sin6_port = 0; + sin6->sin6_flowinfo = 0; + inet_pton (AF_INET6, addr, &sin6->sin6_addr); + sin6->sin6_scope_id = 0; + + storage[i].ia.ifa_netmask = (struct sockaddr *) &storage[i].netmask; + sin6 = ((struct sockaddr_in6 *) &storage[i].netmask); + sin6->sin6_family = AF_INET6; + sin6->sin6_len = sizeof(*sin6); + sin6->sin6_port = 0; + sin6->sin6_flowinfo = 0; + sin6->sin6_addr.s6_addr32[0] = htonl (cidr >= 32 ? 0xffffffffUL : cidr <= 0 ? 0 : ~((1UL << ( 32 - cidr)) - 1)); + sin6->sin6_addr.s6_addr32[1] = htonl (cidr >= 64 ? 0xffffffffUL : cidr <= 32 ? 0 : ~((1UL << ( 64 - cidr)) - 1)); + sin6->sin6_addr.s6_addr32[2] = htonl (cidr >= 96 ? 0xffffffffUL : cidr <= 64 ? 0 : ~((1UL << ( 96 - cidr)) - 1)); + sin6->sin6_addr.s6_addr32[3] = htonl (cidr >= 128 ? 0xffffffffUL : cidr <= 96 ? 0 : ~((1UL << (128 - cidr)) - 1)); + sin6->sin6_scope_id = 0; + + storage[i].ia.ifa_broadaddr = NULL; + storage[i].ia.ifa_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_MULTICAST; + storage[i].ia.ifa_data = NULL; /* Nothing here for now. */ + free (addr); + } + + else if (!strncmp (cur, "--peer6=", 8)) + { + /* IPv6 peer */ + addr = cur + 8; + + storage[i].ia.ifa_dstaddr = (struct sockaddr *) &storage[i].broadaddr; + sin6 = ((struct sockaddr_in6 *) &storage[i].broadaddr); + sin6->sin6_family = AF_INET6; + sin6->sin6_len = sizeof(*sin6); + sin6->sin6_port = 0; + sin6->sin6_flowinfo = 0; + inet_pton (AF_INET6, addr, &sin6->sin6_addr); + sin6->sin6_scope_id = 0; + + storage[i].ia.ifa_flags &= ~IFF_BROADCAST; + storage[i].ia.ifa_flags |= IFF_POINTOPOINT; + } + } + + storage[i].ia.ifa_next = NULL; + + *ifap = &storage[0].ia; + } + + __munmap (argz, argz_len); + + return 0; +} +weak_alias (__getifaddrs, getifaddrs) +libc_hidden_def (__getifaddrs) +#ifndef getifaddrs +libc_hidden_weak (getifaddrs) +#endif + +void +__freeifaddrs (struct ifaddrs *ifa) +{ + free (ifa); +} +weak_alias (__freeifaddrs, freeifaddrs) +libc_hidden_def (__freeifaddrs) +libc_hidden_weak (freeifaddrs) diff --git a/sysdeps/mach/hurd/jmp-unwind.c b/sysdeps/mach/hurd/jmp-unwind.c index 35b496114a..f500741530 100644 --- a/sysdeps/mach/hurd/jmp-unwind.c +++ b/sysdeps/mach/hurd/jmp-unwind.c @@ -47,9 +47,8 @@ _longjmp_unwind (jmp_buf env, int val) /* All access to SS->active_resources must take place inside a critical section where signal handlers cannot run. */ - __spin_lock (&ss->lock); - assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); + __spin_lock (&ss->lock); /* Remove local signal preemptors being unwound past. */ while (ss->preemptors diff --git a/sysdeps/mach/hurd/lsetxattr.c b/sysdeps/mach/hurd/lsetxattr.c index 3f5d335a1a..49487f78fb 100644 --- a/sysdeps/mach/hurd/lsetxattr.c +++ b/sysdeps/mach/hurd/lsetxattr.c @@ -32,5 +32,5 @@ lsetxattr (const char *path, const char *name, const void *value, size_t size, return -1; err = _hurd_xattr_set (port, name, value, size, flags); __mach_port_deallocate (__mach_task_self (), port); - return err ? __hurd_fail (err) : size; + return __hurd_fail (err); } diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c index 3e875f864a..96346689c1 100644 --- a/sysdeps/mach/hurd/recvmsg.c +++ b/sysdeps/mach/hurd/recvmsg.c @@ -24,6 +24,123 @@ #include #include +static unsigned +contains_uid (unsigned int n, __uid_t uids[n], __uid_t uid) +{ + unsigned i; + + for (i = 0; i < n; i++) + if (uids[i] == uid) + return 1; + return 0; +} + +static unsigned +contains_gid (unsigned int n, __gid_t gids[n], __gid_t gid) +{ + unsigned i; + + for (i = 0; i < n; i++) + if (gids[i] == gid) + return 1; + return 0; +} + +/* Check the passed credentials. */ +static error_t +check_auth (mach_port_t rendezvous, + __pid_t pid, + __uid_t uid, __uid_t euid, + __gid_t gid, + int ngroups, __gid_t groups[ngroups]) +{ + error_t err; + mach_msg_type_number_t neuids = CMGROUP_MAX, nauids = CMGROUP_MAX; + mach_msg_type_number_t negids = CMGROUP_MAX, nagids = CMGROUP_MAX; + __uid_t euids_buf[neuids], auids_buf[nauids]; + __gid_t egids_buf[negids], agids_buf[nagids]; + __uid_t *euids = euids_buf, *auids = auids_buf; + __gid_t *egids = egids_buf, *agids = agids_buf; + + struct procinfo *pi = NULL; + mach_msg_type_number_t pi_size = 0; + int flags = PI_FETCH_TASKINFO; + char *tw = NULL; + mach_msg_type_number_t tw_size = 0; + unsigned i; + + err = __mach_port_mod_refs (mach_task_self (), rendezvous, + MACH_PORT_RIGHT_SEND, 1); + if (err) + goto out; + + do + err = __USEPORT + (AUTH, __auth_server_authenticate (port, + rendezvous, MACH_MSG_TYPE_COPY_SEND, + MACH_PORT_NULL, 0, + &euids, &neuids, &auids, &nauids, + &egids, &negids, &agids, &nagids)); + while (err == EINTR); + if (err) + goto out; + + /* Check whether this process indeed has these IDs */ + if ( !contains_uid (neuids, euids, uid) + && !contains_uid (nauids, auids, uid) + || !contains_uid (neuids, euids, euid) + && !contains_uid (nauids, auids, euid) + || !contains_gid (negids, egids, gid) + && !contains_gid (nagids, agids, gid) + ) + { + err = EIO; + goto out; + } + + /* Check groups */ + for (i = 0; i < ngroups; i++) + if ( !contains_gid (negids, egids, groups[i]) + && !contains_gid (nagids, agids, groups[i])) + { + err = EIO; + goto out; + } + + /* Check PID */ + /* XXX: Using proc_getprocinfo until + proc_user_authenticate proc_server_authenticate is implemented + */ + /* Get procinfo to check the owner. Maybe he faked the pid, but at least we + check the owner. */ + err = __USEPORT (PROC, __proc_getprocinfo (port, pid, &flags, + (procinfo_t *)&pi, + &pi_size, &tw, &tw_size)); + if (err) + goto out; + + if ( !contains_uid (neuids, euids, pi->owner) + && !contains_uid (nauids, auids, pi->owner)) + err = EIO; + +out: + __mach_port_deallocate (__mach_task_self (), rendezvous); + if (euids != euids_buf) + __vm_deallocate (__mach_task_self(), (vm_address_t) euids, neuids * sizeof(uid_t)); + if (auids != auids_buf) + __vm_deallocate (__mach_task_self(), (vm_address_t) auids, nauids * sizeof(uid_t)); + if (egids != egids_buf) + __vm_deallocate (__mach_task_self(), (vm_address_t) egids, negids * sizeof(uid_t)); + if (agids != agids_buf) + __vm_deallocate (__mach_task_self(), (vm_address_t) agids, nagids * sizeof(uid_t)); + if (tw_size) + __vm_deallocate (__mach_task_self(), (vm_address_t) tw, tw_size); + if (pi_size) + __vm_deallocate (__mach_task_self(), (vm_address_t) pi, pi_size); + + return err; +} + /* Receive a message as described by MESSAGE from socket FD. Returns the number of bytes read or -1 for errors. */ ssize_t @@ -216,6 +333,21 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) newfds++; } } + else if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDS) + { + /* SCM_CREDS support. */ + /* Check received credentials */ + struct cmsgcred *ucredp = (struct cmsgcred *) CMSG_DATA(cmsg); + + err = check_auth (ports[i], + ucredp->cmcred_pid, + ucredp->cmcred_uid, ucredp->cmcred_euid, + ucredp->cmcred_gid, + ucredp->cmcred_ngroups, ucredp->cmcred_groups); + if (err) + goto cleanup; + i++; + } } for (i = 0; i < nports; i++) @@ -246,6 +378,11 @@ cleanup: __mach_port_deallocate (__mach_task_self (), ports[ii]); } } + else if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDS) + { + __mach_port_deallocate (__mach_task_self (), ports[ii]); + ii++; + } } } diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c index 434815ed7c..3eaaa3d2d1 100644 --- a/sysdeps/mach/hurd/sendmsg.c +++ b/sysdeps/mach/hurd/sendmsg.c @@ -19,11 +19,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include "hurd/hurdsocket.h" @@ -110,6 +112,8 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) nports += (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr))) / sizeof (int); + else if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDS) + nports++; if (nports) ports = __alloca (nports * sizeof (mach_port_t)); @@ -144,6 +148,38 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) goto out; } } + else if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDS) + { + /* SCM_CREDS support: send credentials. */ + mach_port_t rendezvous = __mach_reply_port (), reply; + struct cmsgcred *ucredp; + + err = __mach_port_insert_right (mach_task_self (), rendezvous, + rendezvous, MACH_MSG_TYPE_MAKE_SEND); + ports[nports++] = rendezvous; + if (err) + goto out; + + ucredp = (struct cmsgcred *) CMSG_DATA(cmsg); + /* Fill in credentials data */ + ucredp->cmcred_pid = __getpid(); + ucredp->cmcred_uid = __getuid(); + ucredp->cmcred_euid = __geteuid(); + ucredp->cmcred_gid = __getgid(); + ucredp->cmcred_ngroups = + __getgroups (sizeof (ucredp->cmcred_groups) / sizeof (gid_t), + ucredp->cmcred_groups); + + /* And make auth server authenticate us. */ + reply = __mach_reply_port(); + err = __USEPORT + (AUTH, __auth_user_authenticate_request (port, + reply, MACH_MSG_TYPE_MAKE_SEND_ONCE, + rendezvous, MACH_MSG_TYPE_MAKE_SEND)); + __mach_port_deallocate (__mach_task_self (), reply); + if (err) + goto out; + } } if (addr) diff --git a/sysdeps/mach/hurd/shmat.c b/sysdeps/mach/hurd/shmat.c new file mode 100644 index 0000000000..d6e310e66d --- /dev/null +++ b/sysdeps/mach/hurd/shmat.c @@ -0,0 +1,82 @@ +/* SysV shmat for Hurd. + Copyright (C) 2005-2015 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, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sysvshm.h" + +/* Attach the shared memory segment associated with SHMID to the data + segment of the calling process. SHMADDR and SHMFLG determine how + and where the segment is attached. */ +void * +__shmat (int shmid, const void *shmaddr, int shmflg) +{ + error_t err; + char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX]; + int fd; + void *addr; + struct stat statbuf; + int res; + + sprintf (filename, SHM_DIR SHM_NAMEPRI, shmid); + fd = __open (filename, (shmflg & SHM_RDONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) + { + if (errno == ENOENT) + errno = EINVAL; + return (void *) -1; + } + + res = __fstat (fd, &statbuf); + if (res < 0) + { + err = errno; + __close (fd); + errno = err; + return (void *) -1; + } + + addr = __mmap ((void *) shmaddr, statbuf.st_size, + PROT_READ | ((shmflg & SHM_RDONLY) ? 0 : PROT_WRITE), + MAP_SHARED, fd, 0); + __close (fd); + if (addr == MAP_FAILED) + return (void *) -1; + + err = __sysvshm_add (addr, statbuf.st_size); + if (err) + { + __munmap (addr, statbuf.st_size); + errno = err; + return (void *) -1; + } + + return addr; +} + +weak_alias(__shmat, shmat) diff --git a/sysdeps/mach/hurd/shmctl.c b/sysdeps/mach/hurd/shmctl.c new file mode 100644 index 0000000000..d5e6bbea45 --- /dev/null +++ b/sysdeps/mach/hurd/shmctl.c @@ -0,0 +1,132 @@ +/* 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 +#include +#include +#include + +#include "sysvshm.h" + +/* Provide operations to control over shared memory segments. */ +int +__shmctl (int id, int cmd, struct shmid_ds *buf) +{ + error_t err = 0; + int fd; + int res; + char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX]; + struct stat statbuf; + + sprintf (filename, SHM_DIR SHM_NAMEPRI, id); + /* SysV requires read access for IPC_STAT. */ + fd = __open (filename, O_NORW); + if (fd < 0) + { + if (errno == ENOENT) + errno = EINVAL; + return -1; + } + + res = __fstat (fd, &statbuf); + if (res < 0) + { + err = errno; + __close (fd); + errno = err; + return -1; + } + + switch (cmd) + { + case IPC_STAT: + + buf->shm_perm.__key = id; + buf->shm_perm.uid = statbuf.st_uid; + buf->shm_perm.gid = statbuf.st_gid; + + /* We do not support the creator. */ + buf->shm_perm.cuid = statbuf.st_uid; + buf->shm_perm.cgid = statbuf.st_gid; + + /* We just want the protection bits. */ + buf->shm_perm.mode = statbuf.st_mode & 0777; + /* Hopeless. We do not support a sequence number. */ + buf->shm_perm.__seq = statbuf.st_ino; + buf->shm_segsz = statbuf.st_size; + + /* Hopeless. We do not support any of these. */ + buf->shm_atime = statbuf.st_atime; + buf->shm_dtime = statbuf.st_mtime; + /* Well, this comes at least close. */ + buf->shm_ctime = statbuf.st_ctime; + + /* We do not support the PID. */ + buf->shm_cpid = 0; + buf->shm_lpid = 0; + + if (statbuf.st_mode & S_IMMAP0) + buf->shm_nattch = 0; + else + /* 42 is the answer. Of course this is bogus, but for most + applications, this should be fine. */ + buf->shm_nattch = 42; + + break; + + case IPC_SET: + if (statbuf.st_uid != buf->shm_perm.uid + || statbuf.st_gid != buf->shm_perm.gid) + { + res = __fchown (fd, + (statbuf.st_uid != buf->shm_perm.uid) + ? buf->shm_perm.uid : -1, + (statbuf.st_gid != buf->shm_perm.gid) + ? buf->shm_perm.gid : -1); + if (res < 0) + err = errno; + } + + if (!err && statbuf.st_mode & 0777 != buf->shm_perm.mode & 0777) + { + res = __fchmod (fd, (statbuf.st_mode & ~0777) + | (buf->shm_perm.mode & 0777)); + if (res < 0) + err = errno; + } + break; + + case IPC_RMID: + res = __unlink (filename); + /* FIXME: Check error (mapping ENOENT to EINVAL). */ + break; + + default: + err = EINVAL; + } + + __close (fd); + errno = err; + return err ? -1 : 0; +} + +weak_alias(__shmctl, shmctl) diff --git a/sysdeps/mach/hurd/shmdt.c b/sysdeps/mach/hurd/shmdt.c new file mode 100644 index 0000000000..cdafef0200 --- /dev/null +++ b/sysdeps/mach/hurd/shmdt.c @@ -0,0 +1,51 @@ +/* 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 +#include +#include +#include +#include +#include + +#include "sysvshm.h" + +/* Detach shared memory segment starting at address specified by + SHMADDR from the caller's data segment. */ +int +__shmdt (const void *shmaddr) +{ + error_t err; + size_t size; + + err = __sysvshm_remove ((void *) shmaddr, &size); + if (err) + { + errno = err; + return -1; + } + + __munmap ((void *) shmaddr, size); + return 0; +} + +weak_alias(__shmdt, shmdt) diff --git a/sysdeps/mach/hurd/shmget.c b/sysdeps/mach/hurd/shmget.c new file mode 100644 index 0000000000..79646e5fee --- /dev/null +++ b/sysdeps/mach/hurd/shmget.c @@ -0,0 +1,242 @@ +/* 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 +#include +#include +#include +#include +#include + +#include + +#include "sysvshm.h" + +/* Create a new shared memory segment file without linking it into the + filesystem. Return the directory and file ports in R_DIR and R_FILE. */ +static error_t +create_shm_file (size_t size, int flags, file_t *r_dir, file_t *r_file) +{ + error_t err; + file_t dir; + file_t file; + + flags &= 0777; + + /* Get a port to the directory that will contain the file. */ + dir = __file_name_lookup (SHM_DIR, 0, 0); + if (dir == MACH_PORT_NULL) + return errno; + + /* Create an unnamed file in the directory. */ + err = __dir_mkfile (dir, O_RDWR, flags, &file); + if (err) + { + __mach_port_deallocate (__mach_task_self (), dir); + return err; + } + + err = __file_set_size (file, size); + if (err) + { + __mach_port_deallocate (__mach_task_self (), file); + __mach_port_deallocate (__mach_task_self (), dir); + + return err; + } + + *r_dir = dir; + *r_file = file; + + return 0; +} + + +/* Open the shared memory segment *R_KEY and return a file descriptor + to it in R_FD. If KEY is IPC_PRIVATE, use a private key and return + it in R_KEY. */ +static error_t +get_exclusive (int shmflags, size_t size, key_t *r_key, int *r_fd) +{ + error_t err; + file_t dir; + file_t file; + char filename[SHM_NAMEMAX]; + key_t key = *r_key; + bool is_private; + + /* Create the shared memory segment. */ + err = create_shm_file (size, shmflags, &dir, &file); + if (err) + return err; + + if (key == IPC_PRIVATE) + { + is_private = true; + key = SHM_PRIV_KEY_START; + + /* Try to link the shared memory segment into the filesystem + (exclusively). Private segments have negative keys. */ + do + { + sprintf (filename, SHM_NAMEPRI, key); + err = __dir_link (dir, file, filename, 1); + if (!err) + { + /* We are done. */ + *r_key = key; + break; + } + else if (err == EEXIST) + { + /* Check if we ran out of keys. If not, try again with new + key. */ + if (key == SHM_PRIV_KEY_END) + err = ENOSPC; + else + err = 0; + + key--; + } + } + while (!err); + } + else + { + /* Try to link the shared memory segment into the filesystem + (exclusively) under the given key. */ + sprintf (filename, SHM_NAMEPRI, key); + err = __dir_link (dir, file, filename, 1); + } + + __mach_port_deallocate (__mach_task_self (), dir); + + if (!err) + { + int fd; + + /* Get a file descriptor for that port. */ + fd = _hurd_intern_fd (file, O_RDWR, 1); /* dealloc on error */ + if (fd < 0) + err = errno; + else + *r_fd = fd; + } + + return err; +} + + +/* Open the shared memory segment KEY (creating it if it doesn't yet + exist) and return a file descriptor to it in R_FD. */ +static error_t +get_shared (int shmflags, size_t size, key_t key, int *r_fd) +{ + error_t err = 0; + char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX]; + int fd = -1; + sprintf (filename, SHM_DIR SHM_NAMEPRI, key); + + do + { + fd = __open (filename, O_NORW, shmflags & 0777); + + if (fd < 0 && errno != ENOENT) + /* We give up. */ + return errno; + else if (fd >= 0) + { + int res; + struct stat statbuf; + + /* Check the size (we only need to do this if we did not + create the shared memory segment file ourselves). */ + res = __fstat (fd, &statbuf); + if (res < 0) + { + err = errno; + __close (fd); + return err; + } + + if (statbuf.st_size < size) + { + __close (fd); + return EINVAL; + } + } + else + { + /* The memory segment doesn't exist. */ + if (shmflags & IPC_CREAT) + { + /* Try to create it exclusively. */ + err = get_exclusive (shmflags, size, &key, &fd); + if (err == EEXIST) + /* If somebody created it in the meanwhile, just try again. */ + err = 0; + } + else + err = ENOENT; + } + } + while (fd < 0 && !err); + + if (!err) + *r_fd = fd; + else + *r_fd = -1; + + return err; +} + +/* Return an identifier for an shared memory segment of at least size + SIZE which is associated with KEY. */ +int +__shmget (key_t key, size_t size, int shmflags) +{ + error_t err; + int fd; + + if (key == IPC_PRIVATE || shmflags & IPC_EXCL) + /* An exclusive shared memory segment must be created. */ + err = get_exclusive (shmflags, size, &key, &fd); + else + err = get_shared (shmflags, size, key, &fd); + + if (err) + { + errno = err; + return -1; + } + + /* From here, we can't fail. That's important, as otherwise we + would need to unlink the file if we created it (in that case, the + code above would have to be changed to pass a "created" flag down + to the caller). */ + + __close (fd); + + return key; +} + +weak_alias(__shmget, shmget) diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index a0d2e28c8e..739f905c68 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include "spawn_int.h" @@ -333,7 +334,6 @@ __spawni (pid_t *pid, const char *file, ss = _hurd_self_sigstate (); retry: - assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); _hurd_sigstate_lock (ss); @@ -679,11 +679,29 @@ retry: ref, MACH_MSG_TYPE_MAKE_SEND, &newproc); __mach_port_destroy (__mach_task_self (), ref); - if (!err) - { - __mach_port_deallocate (__mach_task_self (), proc); - proc = newproc; - } + if (err) + goto out; + if (newproc == MACH_PORT_NULL) + { + /* Old versions of the proc server did not recreate the process + port when reauthenticating, and passed MACH_PORT_NULL through + the auth server. That must be what we're dealing with. Just + keep the existing proc port in this case. */ + } + else + { + err = __proc_reauthenticate_complete (newproc); + if (err) + { + __mach_port_deallocate (__mach_task_self (), newproc); + goto out; + } + else + { + __mach_port_deallocate (__mach_task_self (), proc); + proc = newproc; + } + } if (!err) err = reauthenticate (INIT_PORT_CRDIR, &rcrdir); @@ -833,6 +851,18 @@ retry: ints, INIT_INT_MAX, NULL, 0, NULL, 0); + /* Fallback for backwards compatibility. This can just be removed + when __file_exec goes away. */ + if (err == MIG_BAD_ID) + err = __file_exec_file_name + (file, task, + __sigismember (&_hurdsig_traced, SIGKILL) ? EXEC_SIGTRAP : 0, + relpath, args, argslen, env, envlen, + dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize, + ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports, + ints, INIT_INT_MAX, + NULL, 0, NULL, 0); + /* Fallback for backwards compatibility. This can just be removed when __file_exec goes away. */ if (err == MIG_BAD_ID) diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c index dba442d3d9..54ce6f99bd 100644 --- a/sysdeps/mach/hurd/times.c +++ b/sysdeps/mach/hurd/times.c @@ -32,6 +32,13 @@ clock_from_time_value (const time_value_t *t) return t->seconds * 100 + t->microseconds / 10000; } +#ifdef HAVE_HURD_PROC_GETCHILDREN_RUSAGE +static inline clock_t +clock_from_timeval (const struct timeval *t) { + return t->tv_sec * 1000000 + t->tv_usec; +} +#endif + /* Store the CPU time used by this process and all its dead children (and their dead children) in BUFFER. Return the elapsed real time, or (clock_t) -1 for errors. @@ -62,8 +69,17 @@ __times (struct tms *tms) tms->tms_stime = (clock_from_time_value (&bi.system_time) + clock_from_time_value (&tti.system_time)); - /* XXX This can't be implemented until getrusage(RUSAGE_CHILDREN) can be. */ +#ifdef HAVE_HURD_PROC_GETCHILDREN_RUSAGE + struct rusage child_rusage; + err = __USEPORT (PROC, __proc_getchildren_rusage (port, &child_rusage)); + if (err) + return __hurd_fail (err); + + tms->tms_cutime = clock_from_timeval (&child_rusage.ru_utime); + tms->tms_cstime = clock_from_timeval (&child_rusage.ru_stime); +#else tms->tms_cutime = tms->tms_cstime = 0; +#endif __host_get_time (__mach_host_self (), &now); diff --git a/sysdeps/mach/hurd/x86_64/ld.abilist b/sysdeps/mach/hurd/x86_64/ld.abilist index 2297a5f354..65813436f4 100644 --- a/sysdeps/mach/hurd/x86_64/ld.abilist +++ b/sysdeps/mach/hurd/x86_64/ld.abilist @@ -8,6 +8,7 @@ GLIBC_2.38 __open64 F GLIBC_2.38 __pread64 F GLIBC_2.38 __read F GLIBC_2.38 __sbrk F +GLIBC_2.38 __stack_chk_guard D 0x8 GLIBC_2.38 __tls_get_addr F GLIBC_2.38 __write F GLIBC_2.38 __writev F diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist index 7c685645bb..a4f67ed24e 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -572,6 +572,7 @@ GLIBC_2.38 _hurd_dtable_lock D 0x28 GLIBC_2.38 _hurd_dtablesize D 0x4 GLIBC_2.38 _hurd_exception2signal F GLIBC_2.38 _hurd_exec F +GLIBC_2.38 _hurd_exec_file_name F GLIBC_2.38 _hurd_exec_paths F GLIBC_2.38 _hurd_fd_error F GLIBC_2.38 _hurd_fd_error_signal F @@ -607,7 +608,7 @@ GLIBC_2.38 _libc_intl_domainname D 0x5 GLIBC_2.38 _longjmp F GLIBC_2.38 _mcleanup F GLIBC_2.38 _mcount F -GLIBC_2.38 _nl_default_dirname D 0xe +GLIBC_2.38 _nl_default_dirname D 0x12 GLIBC_2.38 _nl_domain_bindings D 0x8 GLIBC_2.38 _nl_msg_cat_cntr D 0x4 GLIBC_2.38 _obstack_allocated_p F diff --git a/sysdeps/mach/libc-lock.h b/sysdeps/mach/libc-lock.h index 63427f7767..b1179d29a6 100644 --- a/sysdeps/mach/libc-lock.h +++ b/sysdeps/mach/libc-lock.h @@ -146,15 +146,15 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t; __libc_lock_unlock_recursive (NAME) /* XXX for now */ -#define __libc_rwlock_define __libc_lock_define -#define __libc_rwlock_define_initialized __libc_lock_define_initialized -#define __libc_rwlock_init __libc_lock_init -#define __libc_rwlock_fini __libc_lock_fini -#define __libc_rwlock_rdlock __libc_lock_lock -#define __libc_rwlock_wrlock __libc_lock_lock -#define __libc_rwlock_tryrdlock __libc_lock_trylock -#define __libc_rwlock_trywrlock __libc_lock_trylock -#define __libc_rwlock_unlock __libc_lock_unlock +#define __libc_rwlock_define __libc_lock_define_recursive +#define __libc_rwlock_define_initialized __libc_lock_define_initialized_recursive +#define __libc_rwlock_init __libc_lock_init_recursive +#define __libc_rwlock_fini __libc_lock_fini_recursive +#define __libc_rwlock_rdlock __libc_lock_lock_recursive +#define __libc_rwlock_wrlock __libc_lock_lock_recursive +#define __libc_rwlock_tryrdlock __libc_lock_trylock_recursive +#define __libc_rwlock_trywrlock __libc_lock_trylock_recursive +#define __libc_rwlock_unlock __libc_lock_unlock_recursive struct __libc_cleanup_frame { diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c index 76a52d8e2c..8f892f4bd9 100644 --- a/sysdeps/posix/clock_getres.c +++ b/sysdeps/posix/clock_getres.c @@ -55,10 +55,6 @@ __clock_getres (clockid_t clock_id, struct timespec *res) switch (clock_id) { case CLOCK_REALTIME: - case CLOCK_MONOTONIC: - case CLOCK_MONOTONIC_RAW: - case CLOCK_REALTIME_COARSE: - case CLOCK_MONOTONIC_COARSE: retval = realtime_getres (res); break;