This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Several GNU/Hurd fixes


The following patch fixes several bugs for GNU/Hurd. The
CFLAGS-init-first.c changes fixes a gcc 3.4 error because it wants to
use ebp in doinit() for the frame pointer, but we already use it in
the assembly code.

The next patch fixes four failing test cases. Test-ifaddrs failed to
compile because AF_PACKET isn't defined on GNU/Hurd so we have to
surround it with an #ifdef. The getcwd patch fixes a bug in getcwd()
that enlarges the buffer greater than the size specified if buf was
NULL. The mmap patch adds checks whether the address and offset
arguments are page-aligned, this is required by POSIX. The posix_spawn
change fixes a bug that the dtablesize variable isn't increased when
the dtable is enlarged (and removes some strange 'v' in a comment).

The Versions change adds __libc_read, __libc_write and __libc_lseek64
GLIBC_PRIVATE symbols back because GNU/Hurd needs them. These were
removed because the other platforms don't need them.

Jeroen Dekkers

2004-05-07  Jeroen Dekkers  <jeroen@dekkers.cx>

	* sysdeps/mach/hurd/i386/Makefile (CFLAGS-init-first.c): Add
	-momit-leaf-frame-pointer.

	* inet/test-ifaddrs.c (addr_string): Surround AF_PACKET case with
	#ifdef AF_PACKET.
	* sysdeps/mach/hurd/getcwd.c
	(_hurd_canonicalize_directory_name_intern): Only realloc when
	size is <= 0.
	* sysdeps/mach/hurd/mmap.c (__mmap): Fail when addr or offset
	isn't page aligned.
	* sysdeps/mach/hurd/spawni.c (EXPAND_DTABLE): Set dtablesize to
	new size.
	
	* sysdeps/mach/hurd/Versions (GLIBC_PRIVATE): Add __libc_read,
	__libc_write and __libc_lseek64.

Index: sysdeps/mach/hurd/i386/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/i386/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- sysdeps/mach/hurd/i386/Makefile	24 Mar 2002 01:55:16 -0000	1.8
+++ sysdeps/mach/hurd/i386/Makefile	20 Mar 2004 19:53:42 -0000
@@ -3,3 +3,6 @@ sysdep_routines += ioperm
 sysdep_headers += sys/io.h
 endif
 
+ifeq ($(subdir),csu)
+CFLAGS-init-first.c += -momit-leaf-frame-pointer
+endif
Index: inet/test-ifaddrs.c
===================================================================
RCS file: /cvs/glibc/libc/inet/test-ifaddrs.c,v
retrieving revision 1.4
diff -u -p -r1.4 test-ifaddrs.c
--- inet/test-ifaddrs.c	4 Apr 2004 00:40:26 -0000	1.4
+++ inet/test-ifaddrs.c	3 May 2004 16:49:33 -0000
@@ -48,8 +48,10 @@ addr_string (struct sockaddr *sa, char *
     case AF_UNSPEC:
       return "---";
 
+#ifdef AF_PACKET
     case AF_PACKET:
       return "<packet>";
+#endif
 
     default:
       ++failures;
Index: sysdeps/mach/hurd/getcwd.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/getcwd.c,v
retrieving revision 1.24
diff -u -p -r1.24 getcwd.c
--- sysdeps/mach/hurd/getcwd.c	15 Jun 2002 22:19:43 -0000	1.24
+++ sysdeps/mach/hurd/getcwd.c	3 May 2004 16:49:33 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,93,94,95,96,97,98,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,98,2002,04 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -50,6 +50,7 @@ _hurd_canonicalize_directory_name_intern
   file_t parent;
   char *dirbuf = NULL;
   unsigned int dirbufsize = 0;
+  const size_t orig_size = size;
 
   inline void cleanup (void)
     {
@@ -67,7 +68,7 @@ _hurd_canonicalize_directory_name_intern
     }
 
 
-  if (size == 0)
+  if (size <= 0)
     {
       if (buf != NULL)
 	{
@@ -226,7 +227,7 @@ _hurd_canonicalize_directory_name_intern
 
 	  if (file_namep - file_name < d->d_namlen + 1)
 	    {
-	      if (buf != NULL)
+	      if (orig_size > 0)
 		{
 		  errno = ERANGE;
 		  return NULL;
Index: sysdeps/mach/hurd/mmap.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/mmap.c,v
retrieving revision 1.19
diff -u -p -r1.19 mmap.c
--- sysdeps/mach/hurd/mmap.c	5 Sep 2003 21:24:54 -0000	1.19
+++ sysdeps/mach/hurd/mmap.c	3 May 2004 16:49:33 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994,1995,1996,1997,1999,2002,2003
+/* Copyright (C) 1994,1995,1996,1997,1999,2002,2003,2004
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -39,10 +39,13 @@ __mmap (__ptr_t addr, size_t len, int pr
   vm_prot_t vmprot;
   memory_object_t memobj;
   vm_address_t mapaddr;
-  vm_size_t pageoff;
 
   mapaddr = (vm_address_t) addr;
 
+  /* ADDR and OFFSET must be page-aligned.  */
+  if ((mapaddr & (vm_page_size - 1)) || (offset & (vm_page_size - 1)))
+    return (__ptr_t) (long int) __hurd_fail (EINVAL);
+
   if ((flags & (MAP_TYPE|MAP_INHERIT)) == MAP_ANON
       && prot == (PROT_READ|PROT_WRITE)) /* cf VM_PROT_DEFAULT */
     {
@@ -62,20 +65,6 @@ __mmap (__ptr_t addr, size_t len, int pr
       return err ? (__ptr_t) (long int) __hurd_fail (err) : (__ptr_t) mapaddr;
     }
 
-  pageoff = offset & (vm_page_size - 1);
-  offset &= ~(vm_page_size - 1);
-
-  if (flags & MAP_FIXED)
-    {
-      /* A specific address is requested.  It need not be page-aligned;
-	 it just needs to be congruent with the object offset.  */
-      if ((mapaddr & (vm_page_size - 1)) != pageoff)
-	return (__ptr_t) (long int) __hurd_fail (EINVAL);
-      else
-	/* We will add back PAGEOFF after mapping.  */
-	mapaddr -= pageoff;
-    }
-
   vmprot = VM_PROT_NONE;
   if (prot & PROT_READ)
     vmprot |= VM_PROT_READ;
@@ -172,9 +161,6 @@ __mmap (__ptr_t addr, size_t len, int pr
 
   if (err)
     return (__ptr_t) (long int) __hurd_fail (err);
-
-  /* Adjust the mapping address for the offset-within-page.  */
-  mapaddr += pageoff;
 
   return (__ptr_t) mapaddr;
 }
Index: sysdeps/mach/hurd/spawni.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/spawni.c,v
retrieving revision 1.3
diff -u -p -r1.3 spawni.c
--- sysdeps/mach/hurd/spawni.c	26 Aug 2002 22:39:46 -0000	1.3
+++ sysdeps/mach/hurd/spawni.c	3 May 2004 16:49:33 -0000
@@ -1,5 +1,5 @@
 /* spawn a new process running an executable.  Hurd version.
-   Copyright (C) 2001,02 Free Software Foundation, Inc.
+   Copyright (C) 2001,02,04 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
@@ -399,6 +399,7 @@ __spawni (pid_t *pid, const char *file,
 	      NEW_TABLE (dtable, newfd);				      \
 	      NEW_TABLE (ulink_dtable, newfd);				      \
 	      NEW_TABLE (dtable_cells, newfd);				      \
+	      dtablesize = newfd + 1;		       		       	      \
 	    }								      \
 	  ((unsigned int)newfd < dtablesize ? 0 : EMFILE);		      \
 	})
@@ -592,7 +593,7 @@ __spawni (pid_t *pid, const char *file,
 	    case ESTALE:
 	    case ENOTDIR:
 	      /* Those errors indicate the file is missing or not executable
-v		 by us, in which case we want to just try the next path
+		 by us, in which case we want to just try the next path
 		 directory.  */
 	      continue;
 
Index: sysdeps/mach/hurd/Versions
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/Versions,v
retrieving revision 1.12
diff -u -p -r1.12 Versions
--- sysdeps/mach/hurd/Versions	29 Sep 2002 22:47:52 -0000	1.12
+++ sysdeps/mach/hurd/Versions	7 May 2004 08:59:45 -0000
@@ -4,6 +4,9 @@ libc {
     __getcwd; __mmap;
   }
   GLIBC_PRIVATE {
+    # Functions shared with the dynamic linker
+    __libc_read; __libc_write; __libc_lseek64;
+
     _dl_init_first;
   }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]