about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/accept.c5
-rw-r--r--sysdeps/mach/hurd/chroot.c13
-rw-r--r--sysdeps/mach/hurd/defs.c4
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c4
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c8
-rw-r--r--sysdeps/mach/hurd/readlink.c52
-rw-r--r--sysdeps/posix/defs.c4
-rw-r--r--sysdeps/stub/defs.c4
8 files changed, 45 insertions, 49 deletions
diff --git a/sysdeps/mach/hurd/accept.c b/sysdeps/mach/hurd/accept.c
index 528d4252fd..18c5f75199 100644
--- a/sysdeps/mach/hurd/accept.c
+++ b/sysdeps/mach/hurd/accept.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1994, 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
@@ -38,7 +38,7 @@ DEFUN(accept, (fd, addr, addr_len),
   socket_t new;
   addr_port_t aport;
   char *buf = (char *) addr;
-  mach_msg_type_number_t buflen = *addr_len;
+  mach_msg_type_number_t buflen;
   int type;
 
   if (err = HURD_DPORT_USE (fd, __socket_accept (port, &new, &aport)))
@@ -46,6 +46,7 @@ DEFUN(accept, (fd, addr, addr_len),
 
   if (addr != NULL)
     {
+      buflen = *addr_len;
       err = __socket_whatis_address (aport, &type, &buf, &buflen);
       if (err == EOPNOTSUPP)
 	/* If the protocol server can't tell us the address, just return a
diff --git a/sysdeps/mach/hurd/chroot.c b/sysdeps/mach/hurd/chroot.c
index f010c368ed..c39493e272 100644
--- a/sysdeps/mach/hurd/chroot.c
+++ b/sysdeps/mach/hurd/chroot.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 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
@@ -28,7 +28,8 @@ Cambridge, MA 02139, USA.  */
 int
 DEFUN(chroot, (file_name), CONST char *file_name)
 {
-  file_t file, dir;
+  error_t err;
+  file_t file, dir, root;
 
   file = __file_name_lookup (file_name, O_EXEC, 0);
   if (file == MACH_PORT_NULL)
@@ -38,6 +39,12 @@ DEFUN(chroot, (file_name), CONST char *file_name)
   if (dir == MACH_PORT_NULL)
     return -1;
 
-  _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
+  /* Prevent going through DIR's .. */
+  err = __file_reparent (dir, MACH_PORT_NULL, &root);
+  __mach_port_deallocate (__mach_task_self (), dir);
+  if (err)
+    return __hurd_fail (err);
+
+  _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], root);
   return 0;
 }
diff --git a/sysdeps/mach/hurd/defs.c b/sysdeps/mach/hurd/defs.c
index b2cfe7c4ff..b3b66f6296 100644
--- a/sysdeps/mach/hurd/defs.c
+++ b/sysdeps/mach/hurd/defs.c
@@ -1,6 +1,6 @@
 /* Definitions of global stdio data structures.
 
-Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1991, 1992, 1993, 1994, 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
@@ -80,6 +80,6 @@ text_set_element (_hurd_fd_subinit, init_stdio);
 void
 DEFUN_VOID(_cleanup)
 {
-  (void) fclose ((FILE *) NULL);
+  __fcloseall ();
 }
 text_set_element (__libc_atexit, _cleanup);
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index bf1462a899..e8388c4191 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -52,12 +52,8 @@ unsigned int __hurd_threadvar_max = _HURD_THREADVAR_MAX;
 static unsigned long int threadvars[_HURD_THREADVAR_MAX];
 unsigned long int __hurd_threadvar_stack_offset
   = (unsigned long int) &threadvars;
-unsigned long int __hurd_sigthread_stack_base;
-unsigned long int __hurd_sigthread_stack_end;
-unsigned long int *__hurd_sigthread_variables;
 unsigned long int __hurd_threadvar_stack_mask;
 
-
 /* XXX loser kludge for vm_map kernel bug */
 static vm_address_t fmha;
 static vm_size_t fmhs;
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index c9249bba4e..4c4f6ff665 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -30,10 +30,14 @@ extern void __libc_init (int, char **, char **);
 extern void __getopt_clean_environment (void);
 extern void __libc_global_ctors (void);
 
+unsigned int __hurd_threadvar_max;
+unsigned long int __hurd_threadvar_stack_offset;
+unsigned long int __hurd_threadvar_stack_mask;
+
 int __libc_multiple_libcs = 1;
 
-int __libc_argc;
-char **__libc_argv;
+extern int __libc_argc;
+extern char **__libc_argv;
 
 /* We often need the PID.  Cache this value.  */
 pid_t __libc_pid;
diff --git a/sysdeps/mach/hurd/readlink.c b/sysdeps/mach/hurd/readlink.c
index 2f51e200b5..d04ae1e07a 100644
--- a/sysdeps/mach/hurd/readlink.c
+++ b/sysdeps/mach/hurd/readlink.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 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
@@ -32,45 +32,33 @@ DEFUN(__readlink, (file_name, buf, len),
 {
   error_t err;
   file_t file;
-  char mybuf[2048], *transp = mybuf;
-  mach_msg_type_number_t translen = sizeof (mybuf);
+  struct stat st;
 
-  file = __file_name_lookup (file_name, O_NOTRANS, 0);
+  file = __file_name_lookup (file_name, O_READ | O_NOLINK, 0);
   if (file == MACH_PORT_NULL)
     return -1;
 
-  err = __file_get_translator (file, &transp, &translen);
+  err = __io_stat (file, &st);
+  if (! err)
+    if (S_ISLNK (st.st_mode))
+      {
+	char *rbuf = buf;
+
+	err = __io_read (file, &rbuf, &len, 0, len);
+	if (!err && rbuf != buf)
+	  {
+	    memcpy (buf, rbuf, len);
+	    __vm_deallocate (__mach_task_self (), (vm_address_t)rbuf, len);
+	  }
+      }
+    else
+      err = EINVAL;
+
   __mach_port_deallocate (__mach_task_self (), file);
 
   if (err)
     return __hurd_fail (err);
-
-  if (translen < sizeof (_HURD_SYMLINK) ||
-      memcmp (transp, _HURD_SYMLINK, sizeof (_HURD_SYMLINK)))
-    /* The file is not actually a symlink.  */
-    err = EINVAL;
   else
-    {
-      /* This is a symlink; its translator is "/hurd/symlink\0target\0".  */
-      if (len >= translen - sizeof (_HURD_SYMLINK))
-	{
-	  len = translen - sizeof (_HURD_SYMLINK);
-	  if (transp[translen - 1] == '\0')
-	    /* Remove the null terminator.  */
-	    --len;
-	}
-      if (buf == NULL)
-	/* This call is just to find out how large a buffer is required.  */
-	len = translen - sizeof (_HURD_SYMLINK) - 1;
-      else
-	/* Copy into the user's buffer.  */
-	memcpy (buf, transp + sizeof (_HURD_SYMLINK), len);
-    }
-
-  if (transp != mybuf)
-    __vm_deallocate (__mach_task_self (), (vm_address_t) transp, translen);
-
-  return err ? __hurd_fail (err) : len;
+    return len;
 }
-
 weak_alias (__readlink, readlink)
diff --git a/sysdeps/posix/defs.c b/sysdeps/posix/defs.c
index fcbaf16f69..e3e46377f0 100644
--- a/sysdeps/posix/defs.c
+++ b/sysdeps/posix/defs.c
@@ -1,6 +1,6 @@
 /* Definitions of global stdio data structures.
 
-Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+Copyright (C) 1991, 1993, 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
@@ -67,7 +67,7 @@ FILE *__stdio_head = &stdstreams[0];
 void
 DEFUN_VOID(_cleanup)
 {
-  (void) fclose((FILE *) NULL);
+  __fcloseall ();
 }
 
 
diff --git a/sysdeps/stub/defs.c b/sysdeps/stub/defs.c
index 66f4c4dd24..4fd7ab3615 100644
--- a/sysdeps/stub/defs.c
+++ b/sysdeps/stub/defs.c
@@ -1,6 +1,6 @@
 /* Definitions of global stdio data structures.
 
-Copyright (C) 1991, 1995 Free Software Foundation, Inc.
+Copyright (C) 1991, 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
@@ -40,7 +40,7 @@ FILE *__stdio_head;
 void
 DEFUN_VOID(_cleanup)
 {
-  (void) fclose((FILE *) NULL);
+  __fcloseall ();
 }