about summary refs log tree commit diff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
authorThomas Bushnell, BSG <thomas@gnu.org>1996-11-15 19:50:04 +0000
committerThomas Bushnell, BSG <thomas@gnu.org>1996-11-15 19:50:04 +0000
commitebe3b3ebb7cf39cf3c64a2c69e5a71e2b53fe73f (patch)
treef15f3170c01642634de7bb7e27d3cf01cd8a72ca /sysdeps/mach/hurd
parent63afd6ae4063981afa88e90f8b2b3653433fdcb8 (diff)
downloadglibc-ebe3b3ebb7cf39cf3c64a2c69e5a71e2b53fe73f.tar.gz
glibc-ebe3b3ebb7cf39cf3c64a2c69e5a71e2b53fe73f.tar.xz
glibc-ebe3b3ebb7cf39cf3c64a2c69e5a71e2b53fe73f.zip
Fri Nov 15 12:27:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
	* sysdeps/posix/readv.c (readv): Change return type to ssize_t.
  	Deansideclized.
	* sysdeps/posix/writev.c (writev): Likewise.
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c2
-rw-r--r--sysdeps/mach/hurd/ioctl.c2
-rw-r--r--sysdeps/mach/hurd/lchown.c44
-rw-r--r--sysdeps/mach/hurd/select.c191
-rw-r--r--sysdeps/mach/hurd/statbuf.h16
5 files changed, 162 insertions, 93 deletions
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 331362370b..f898e9a669 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -256,7 +256,7 @@ __libc_init_first (int argc __attribute__ ((unused)), ...)
    cause ld.so to gain an init function, which is not a cool thing. */
 
 void 
-_dl_start () 
+_dl_start (void) 
 { 
   abort (); 
 }
diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
index 24bfbed943..c10ba92e2c 100644
--- a/sysdeps/mach/hurd/ioctl.c
+++ b/sysdeps/mach/hurd/ioctl.c
@@ -27,7 +27,7 @@ Cambridge, MA 02139, USA.  */
 #include <assert.h>
 #include <string.h>
 #include <hurd/ioctl.h>
-
+#include <mach/mig_support.h>
 
 #define typesize(type)	(1 << (type))
 
diff --git a/sysdeps/mach/hurd/lchown.c b/sysdeps/mach/hurd/lchown.c
new file mode 100644
index 0000000000..72d525571c
--- /dev/null
+++ b/sysdeps/mach/hurd/lchown.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 1994, 1995, 1996 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <fcntl.h>
+
+/* Change the owner and group of FILE; if it's a link, do the link and
+   not the target.  */
+int
+__lchown (file, owner, group)
+     const char *file;
+     uid_t owner;
+     gid_t group;
+{
+  error_t err;
+  file_t port = __file_name_lookup (file, O_NOLINK, 0);
+  if (port == MACH_PORT_NULL)
+    return -1;
+  err = __file_chown (port, owner, group);
+  __mach_port_deallocate (__mach_task_self (), port);
+  if (err)
+    return __hurd_fail (err);
+  return 0;
+}
+
+weak_alias (__lchown, lchown)
diff --git a/sysdeps/mach/hurd/select.c b/sysdeps/mach/hurd/select.c
index 60bb489612..aa99944e84 100644
--- a/sysdeps/mach/hurd/select.c
+++ b/sysdeps/mach/hurd/select.c
@@ -117,67 +117,76 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
     return -1;
 
   /* Send them all io_select request messages.  */
-  err = 0;
-  got = 0;
-  portset = MACH_PORT_NULL;
-  for (i = firstfd; i <= lastfd; ++i)
-    if (d[i].type)
-      {
-	int type = d[i].type;
-	d[i].reply_port = __mach_reply_port ();
-	err = __io_select (d[i].io_port, d[i].reply_port,
-			   /* Poll only when there's a single descriptor.  */
-			   (firstfd == lastfd) ? to : 0,
-			   &type);
-	switch (err)
+		     
+  if (firstfd == -1)
+    /* But not if there were no ports to deal with at all. */
+    portset = __mach_reply_port ();
+  else
+    {
+      err = 0;
+      got = 0;
+      portset = MACH_PORT_NULL;
+      
+      for (i = firstfd; i <= lastfd; ++i)
+	if (d[i].type)
 	  {
-	  case MACH_RCV_TIMED_OUT:
-	    /* No immediate response.  This is normal.  */
-	    err = 0;
-	    if (firstfd == lastfd)
-	      /* When there's a single descriptor, we don't need a portset,
-		 so just pretend we have one, but really use the single reply
-		 port.  */
-	      portset = d[i].reply_port;
-	    else if (got == 0)
-	      /* We've got multiple reply ports, so we need a port set to
-		 multiplex them.  */
+	    int type = d[i].type;
+	    d[i].reply_port = __mach_reply_port ();
+	    err = __io_select (d[i].io_port, d[i].reply_port,
+			       /* Poll only if there's a single descriptor.  */
+			       (firstfd == lastfd) ? to : 0,
+			       &type);
+	    switch (err)
 	      {
-		/* We will wait again for a reply later.  */
-		if (portset == MACH_PORT_NULL)
-		  /* Create the portset to receive all the replies on.  */
-		  err = __mach_port_allocate (__mach_task_self (),
-					      MACH_PORT_RIGHT_PORT_SET,
-					      &portset);
-		if (! err)
-		  /* Put this reply port in the port set.  */
-		  __mach_port_move_member (__mach_task_self (),
-					   d[i].reply_port, portset);
+	      case MACH_RCV_TIMED_OUT:
+		/* No immediate response.  This is normal.  */
+		err = 0;
+		if (firstfd == lastfd)
+		  /* When there's a single descriptor, we don't need a
+		     portset, so just pretend we have one, but really
+		     use the single reply port.  */
+		  portset = d[i].reply_port;
+		else if (got == 0)
+		  /* We've got multiple reply ports, so we need a port set to
+		     multiplex them.  */
+		  {
+		    /* We will wait again for a reply later.  */
+		    if (portset == MACH_PORT_NULL)
+		      /* Create the portset to receive all the replies on.  */
+		      err = __mach_port_allocate (__mach_task_self (),
+						  MACH_PORT_RIGHT_PORT_SET,
+						  &portset);
+		    if (! err)
+		      /* Put this reply port in the port set.  */
+		      __mach_port_move_member (__mach_task_self (),
+					       d[i].reply_port, portset);
+		  }
+		break;
+
+	      default:
+		/* No other error should happen.  Callers of select
+		   don't expect to see errors, so we simulate
+		   readiness of the erring object and the next call
+		   hopefully will get the error again.  */
+		type = SELECT_ALL;
+		/* FALLTHROUGH */
+
+	      case 0:
+		/* We got an answer.  */
+		if ((type & SELECT_ALL) == 0)
+		  /* Bogus answer; treat like an error, as a fake positive.  */
+		  type = SELECT_ALL;
+		
+		/* This port is already ready already.  */
+		d[i].type &= type;
+		d[i].type |= SELECT_RETURNED;
+		++got;
+		break;
 	      }
-	    break;
-
-	  default:
-	    /* No other error should happen.  Callers of select don't
-	       expect to see errors, so we simulate readiness of the erring
-	       object and the next call hopefully will get the error again.  */
-	    type = SELECT_ALL;
-	    /* FALLTHROUGH */
-
-	  case 0:
-	    /* We got an answer.  */
-	    if ((type & SELECT_ALL) == 0)
-	      /* Bogus answer; treat like an error, as a fake positive.  */
-	      type = SELECT_ALL;
-
-	    /* This port is already ready already.  */
-	    d[i].type &= type;
-	    d[i].type |= SELECT_RETURNED;
-	    ++got;
-	    break;
+	    _hurd_port_free (&d[i].cell->port, &d[i].ulink, d[i].io_port);
 	  }
-	_hurd_port_free (&d[i].cell->port, &d[i].ulink, d[i].io_port);
-      }
-
+    }
+  
   /* Now wait for reply messages.  */
   if (!err && got == 0)
     {
@@ -234,7 +243,7 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
 		  (msg.success.result & SELECT_ALL) == 0)
 		{
 		  /* Error or bogus reply.  Simulate readiness.  */
-		  __mach_msg_destroy (&msg);
+		  __mach_msg_destroy (&msg.head);
 		  msg.success.result = SELECT_ALL;
 		}
 
@@ -242,13 +251,15 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
                  readiness.  */
 	      {
 		int had = got;
-		for (i = firstfd; i <= lastfd; ++i)
-		  if (d[i].type && d[i].reply_port == msg.head.msgh_local_port)
-		    {
-		      d[i].type &= msg.success.result;
-		      d[i].type |= SELECT_RETURNED;
-		      ++got;
-		    }
+		if (firstfd != -1)
+		  for (i = firstfd; i <= lastfd; ++i)
+		    if (d[i].type
+			&& d[i].reply_port == msg.head.msgh_local_port)
+		      {
+			d[i].type &= msg.success.result;
+			d[i].type |= SELECT_RETURNED;
+			++got;
+		      }
 		assert (got > had);
 	      }
 	    }
@@ -280,10 +291,11 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
 	err = 0;
     }
 
-  for (i = firstfd; i <= lastfd; ++i)
-    if (d[i].type)
-      __mach_port_destroy (__mach_task_self (), d[i].reply_port);
-  if (firstfd != lastfd && portset != MACH_PORT_NULL)
+  if (firstfd != -1)
+    for (i = firstfd; i <= lastfd; ++i)
+      if (d[i].type)
+	__mach_port_destroy (__mach_task_self (), d[i].reply_port);
+  if (firstfd == -1 || (firstfd != lastfd && portset != MACH_PORT_NULL))
     /* Destroy PORTSET, but only if it's not actually the reply port for a
        single descriptor (in which case it's destroyed in the previous loop;
        not doing it here is just a bit more efficient).  */
@@ -298,26 +310,27 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
 
   /* Set the user bitarrays.  We only ever have to clear bits, as all desired
      ones are initially set.  */
-  for (i = firstfd; i <= lastfd; ++i)
-    {
-      int type = d[i].type;
-
-      if ((type & SELECT_RETURNED) == 0)
-	type = 0;
-
-      if (type & SELECT_READ)
-	got++;
-      else if (readfds)
-	FD_CLR (i, readfds);
-      if (type & SELECT_WRITE)
-	got++;
-      else if (writefds)
-	FD_CLR (i, writefds);
-      if (type & SELECT_URG)
-	got++;
-      else if (exceptfds)
-	FD_CLR (i, exceptfds);
-    }
+  if (firstfd != -1)
+    for (i = firstfd; i <= lastfd; ++i)
+      {
+	int type = d[i].type;
+	
+	if ((type & SELECT_RETURNED) == 0)
+	  type = 0;
+
+	if (type & SELECT_READ)
+	  got++;
+	else if (readfds)
+	  FD_CLR (i, readfds);
+	if (type & SELECT_WRITE)
+	  got++;
+	else if (writefds)
+	  FD_CLR (i, writefds);
+	if (type & SELECT_URG)
+	  got++;
+	else if (exceptfds)
+	  FD_CLR (i, exceptfds);
+      }
 
   return got;
 }
diff --git a/sysdeps/mach/hurd/statbuf.h b/sysdeps/mach/hurd/statbuf.h
index c1d8e8f75c..a8f92cb5ed 100644
--- a/sysdeps/mach/hurd/statbuf.h
+++ b/sysdeps/mach/hurd/statbuf.h
@@ -106,8 +106,20 @@ struct stat
    protection bits for unknown users.  */
 #define S_IUNKSHIFT	12
 
-/* All the unused bits.  */
-#define	S_ISPARE	(~(S_IFMT|S_INOCACHE|S_IUNKNOWN|07777))
+/* Read only bits: */
+
+/* There is a passive translator set for this file */
+#define S_IPTRANS	000010000000
+/* There is an active translator running on this file */
+#define S_IATRANS	000020000000
+/* This is the root of a filesystem (or single node translator) */
+#define S_IROOT		000040000000
+/* All the bits relevant to translators */
+#define S_ITRANS	000070000000
+
+/* ALL the unused bits.  */
+#define	S_ISPARE	(~(S_IFMT|S_ITRANS|S_INOCACHE|    \
+			   S_IUSEUNK|S_IUNKNOWN|07777))
 #endif
 
 /* Default file creation mask (umask).  */