commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 01/04: New upstream snapshot


From: Samuel Thibault
Subject: [hurd] 01/04: New upstream snapshot
Date: Tue, 13 Oct 2015 00:09:53 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch master
in repository hurd.

commit 2c2c4d1a59633ffde52472c86f905375a6215854
Author: Samuel Thibault <address@hidden>
Date:   Mon Oct 12 22:08:23 2015 +0000

    New upstream snapshot
---
 .gitignore                       |  12 ++++
 NEWS                             |  18 ++++++
 devnode/devnode.c                |  27 ++++----
 doc/hurd.texi                    |  34 +++++-----
 eth-filter/filter.c              |  30 ++++-----
 exec/main.c                      |  52 +++++++++------
 libddekit/memory.c               |   2 +-
 libdiskfs/boot-start.c           |  11 +++-
 libmachdev/trivfs_server.c       |  29 ++++-----
 libnetfs/io-reauthenticate.c     |  15 ++++-
 libports/inhibit-all-rpcs.c      |   1 -
 libports/inhibit-class-rpcs.c    |   2 -
 libshouldbeinlibc/idvec-rep.c    |   4 +-
 libshouldbeinlibc/idvec-verify.c |   7 +-
 libtrivfs/io-reauthenticate.c    |   3 +-
 libtrivfs/mig-decls.h            | 136 +++++++++++++++------------------------
 libtrivfs/trivfs.h               |  11 ++--
 pfinet/main.c                    |  61 ++++++++++--------
 pfinet/options.c                 |   8 +--
 pfinet/pfinet.h                  |   7 +-
 pfinet/socket-ops.c              |   2 +-
 pflocal/pflocal.c                |  20 ++----
 trans/crash.c                    |  50 +++++++-------
 trans/fakeroot.c                 |  24 +++----
 trans/ifsock.c                   |   7 --
 trans/magic.c                    |  16 +++--
 trans/new-fifo.c                 |  28 ++++----
 trans/password.c                 |  48 ++++++++------
 trans/proxy-defpager.c           |  13 +++-
 29 files changed, 358 insertions(+), 320 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1719508..73f9097 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,15 @@ autom4te.cache/
 /config.status
 /configure
 /version.h
+/doc/hurd.aux
+/doc/hurd.cp
+/doc/hurd.cps
+/doc/hurd.fn
+/doc/hurd.ky
+/doc/hurd.log
+/doc/hurd.pdf
+/doc/hurd.pg
+/doc/hurd.sc
+/doc/hurd.toc
+/doc/hurd.tp
+/doc/hurd.vr
diff --git a/NEWS b/NEWS
index 2b68131..6e034d9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,21 @@
+Version 0.7 (2015-10-XX)
+
+The node cache in ext2fs has been improved, generalized, and moved to
+libdiskfs.  It is now also used by isofs and fatfs.
+
+The native fakeroot tool has been greatly improved.  It now handles
+named sockets, and multiple corner cases related to permissions were
+identified and fixed.
+
+A new utility `rpcscan' has been introduced.  It scans Mach servers
+and displays the RPCs handled by the associated demuxer.
+
+A long-standing synchronization issue involving the filesystem
+translators, libdiskfs, and libpager has been identified and fixed.
+
+The code has been updated to work with newer versions of the compiler
+and libc, and numerous bugs have been fixed throughout the code.
+
 Version 0.6 (2015-04-10)
 
 Numerous cleanups and stylistic fixes of the code base.  Several
diff --git a/devnode/devnode.c b/devnode/devnode.c
index f9f0359..6ec8a65 100644
--- a/devnode/devnode.c
+++ b/devnode/devnode.c
@@ -73,10 +73,9 @@ int trivfs_support_write = 0;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = O_READ | O_WRITE;
 
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
+/* Our port classes.  */
+struct port_class *trivfs_protid_class;
+struct port_class *trivfs_cntl_class;
 
 static int
 devnode_demuxer (mach_msg_header_t *inp,
@@ -270,18 +269,18 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   int count;
 
   /* Stop new requests.  */
-  ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-  ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+  ports_inhibit_class_rpcs (trivfs_cntl_class);
+  ports_inhibit_class_rpcs (trivfs_protid_class);
 
-  count = ports_count_class (trivfs_protid_portclasses[0]);
+  count = ports_count_class (trivfs_protid_class);
   debug ("the number of ports alive: %d\n", count);
 
   if (count && !(flags & FSYS_GOAWAY_FORCE)) 
     {
       /* We won't go away, so start things going again...  */
-      ports_enable_class (trivfs_protid_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_protid_portclasses[0]); 
+      ports_enable_class (trivfs_protid_class);
+      ports_resume_class_rpcs (trivfs_cntl_class);
+      ports_resume_class_rpcs (trivfs_protid_class);
       return EBUSY;
     } 
 
@@ -326,8 +325,8 @@ main (int argc, char *argv[])
   const struct argp argp = { options, parse_opt, args_doc, doc };
 
   port_bucket = ports_create_bucket ();
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
+  trivfs_cntl_class = ports_create_class (trivfs_clean_cntl, 0);
+  trivfs_protid_class = ports_create_class (trivfs_clean_protid, 0);
 
   argp_parse (&argp, argc, argv, 0, 0, 0);
 
@@ -344,8 +343,8 @@ main (int argc, char *argv[])
 
   /* Reply to our parent.  */
   err = trivfs_startup (bootstrap, 0,
-                       trivfs_cntl_portclasses[0], port_bucket,
-                       trivfs_protid_portclasses[0], port_bucket, &fsys);
+                       trivfs_cntl_class, port_bucket,
+                       trivfs_protid_class, port_bucket, &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (1, err, "Contacting parent");
diff --git a/doc/hurd.texi b/doc/hurd.texi
index 2f36bdc..21a7895 100644
--- a/doc/hurd.texi
+++ b/doc/hurd.texi
@@ -386,7 +386,7 @@ libraries they use.  At that point, you should be able to 
study the
 source code of existing Hurd servers and understand how they use the
 Hurd libraries.
 
-The final level of mastery is learning the about the RPC interfaces
+The final level of mastery is learning about the RPC interfaces
 which the Hurd libraries implement.  The last section of each chapter
 describes any Hurd interfaces used in that subsystem.  Those sections
 assume that you are perusing the referenced interface definitions as you
@@ -670,18 +670,19 @@ $ @kbd{boot -d -D /mnt -I /mnt/boot/servers.boot 
/dev/hd2s1}
 See @pxref{Invoking boot} for help with boot.
 @end enumerate
 
-Note that it is impossible to share microkernel devices between the two
-running Hurds, so don't get any funny ideas.  When you're finished
-testing your new Hurd, then you can run the @command{halt} or @command{reboot}
-programs to return control to the parent Hurd.
+If you do not know what you are doing, sharing microkernel devices
+between two running hurds could cause serious harm.  For example, two
+hurds with two filesystems writing to the same partition will wreak
+havoc.  In the same way, two hurds reading from the same terminal
+device will not share nicely.
 
address@hidden FIXME: the `don't get any funny ideas' comment is confusing.  Am
address@hidden I genuinely in some sort of danger if I contemplate sharing
address@hidden microkernel devices between two running Hurds?
address@hidden  tb: not if you know what you are doing.  But there is no clever
address@hidden  device mediation going on.  Two hurds, with two filesystems 
writing
address@hidden  the same partition, will wreak havoc.  Two hurds reading from 
the
address@hidden  same terminal device will not share nicely.
+However, sharing is possible for network devices. The different pfinet
+instances will just pick the packets applying to them, based on
+IP. There is also a proper user-space multiplexer for network devices
+now, called eth-multiplexer. This is only needed though if you also
+want to allow network traffic between the Hurd instances uning the
+device in question, rather than just each of them communicating with
+other machines.
 
 If you're satisfied with your new Hurd, you can arrange for your
 bootloader to start it, and reboot your machine.  Then, you'll be in a
@@ -770,8 +771,10 @@ If neither @option{--interleave} or @option{--layer} is 
specified, multiple
 @scindex halt
 @scindex reboot
 
-FIXME: finish
+You can shut down your GNU/Hurd machine by typing
 
+$ @kbd{su}
+# @kbd{halt}
 
 @node Foundations
 @chapter Foundations
@@ -820,11 +823,8 @@ the microkernel and the underlying hardware.  The Hurd 
threads library,
 @code{libthreads}, contains the default Hurd thread implementation, which
 is declared in @code{<cthreads.h>}.
 
-Currently (April 1998), the Hurd uses cthreads, which have already been
-documented thoroughly by CMU.  Eventually, it will be migrated to use
-POSIX pthreads, which are documented in a lot of places.
+The Hurd uses POSIX pthreads, which are documented in a lot of places.
 @c Thomas, 26-03-1998
-
 @c FIXME: it would be nice if we referred specifically to some of
 @c the places in which POSIX pthreads are documented.
 @c  tb: yes, but alas we are only allowed to refer to free
diff --git a/eth-filter/filter.c b/eth-filter/filter.c
index 13dd03b..74a1e86 100644
--- a/eth-filter/filter.c
+++ b/eth-filter/filter.c
@@ -125,11 +125,6 @@ int trivfs_support_write = 0;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = O_READ | O_WRITE;
 
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
-
 /* For getting the notification of ports from the kernel. */
 struct port_info *notify_pi;
 
@@ -194,6 +189,10 @@ clean_proxy_device (void *p)
     device->proxy->device = NULL;
 }
 
+/* Our port classes.  */
+struct port_class *trivfs_protid_class;
+struct port_class *trivfs_cntl_class;
+
 int
 ethernet_demuxer (mach_msg_header_t *inp,
                  mach_msg_header_t *outp)
@@ -206,7 +205,8 @@ ethernet_demuxer (mach_msg_header_t *inp,
   if (inp->msgh_id != NET_RCV_MSG_ID)
     return 0;
 
-  device = ports_lookup_port (port_bucket, inp->msgh_local_port, 
device_portclass);
+  device = ports_lookup_port (port_bucket, inp->msgh_local_port,
+                              device_portclass);
   if (device == NULL)
     return 0;
   proxy = device->proxy;
@@ -561,8 +561,8 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   int count;
 
   /* Stop new requests.  */
-  ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-  ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+  ports_inhibit_class_rpcs (trivfs_cntl_class);
+  ports_inhibit_class_rpcs (trivfs_protid_class);
 
   count = ports_count_class (user_portclass);
   debug ("the number of ports alive: %d\n", count);
@@ -570,9 +570,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   if (count && !(flags & FSYS_GOAWAY_FORCE)) 
     {
       /* We won't go away, so start things going again...  */
-      ports_enable_class (trivfs_protid_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_protid_portclasses[0]); 
+      ports_enable_class (trivfs_protid_class);
+      ports_resume_class_rpcs (trivfs_cntl_class);
+      ports_resume_class_rpcs (trivfs_protid_class);
       return EBUSY;
     } 
 
@@ -757,8 +757,8 @@ main (int argc, char *argv[])
   user_portclass = ports_create_class (clean_proxy_user, 0);
   device_portclass = ports_create_class (clean_proxy_device, 0);
   other_portclass = ports_create_class (0, 0);
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
+  trivfs_cntl_class = ports_create_class (trivfs_clean_cntl, 0);
+  trivfs_protid_class = ports_create_class (trivfs_clean_protid, 0);
 
   argp_parse (&argp, argc, argv, 0, 0, 0);
 
@@ -785,8 +785,8 @@ main (int argc, char *argv[])
 
   /* Reply to our parent.  */
   err = trivfs_startup (bootstrap, 0,
-                       trivfs_cntl_portclasses[0], port_bucket,
-                       trivfs_protid_portclasses[0], port_bucket, &fsys);
+                       trivfs_cntl_class, port_bucket,
+                       trivfs_protid_class, port_bucket, &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (1, err, "Contacting parent");
diff --git a/exec/main.c b/exec/main.c
index c86c000..beb6f61 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -25,6 +25,7 @@
 #include <hurd/paths.h>
 #include <hurd/startup.h>
 #include <argp.h>
+#include <argz.h>
 #include <version.h>
 #include <pids.h>
 
@@ -37,10 +38,9 @@ int trivfs_support_read = 0;
 int trivfs_support_write = 0;
 int trivfs_allow_open = 0;
 
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
+/* Our port classes.  */
+struct port_class *trivfs_protid_class;
+struct port_class *trivfs_control_class;
 
 struct trivfs_control *fsys;
 
@@ -87,11 +87,11 @@ deadboot (void *p)
   munmap (boot->intarray, boot->nints * sizeof (int));
 
   /* See if we are going away and this was the last thing keeping us up.  */
-  if (ports_count_class (trivfs_cntl_portclasses[0]) == 0)
+  if (ports_count_class (trivfs_control_class) == 0)
     {
       /* We have no fsys control port, so we are detached from the
         parent filesystem.  Maybe we have no users left either.  */
-      if (ports_count_class (trivfs_protid_portclasses[0]) == 0)
+      if (ports_count_class (trivfs_protid_class) == 0)
        {
          /* We have no user ports left.  Are we still listening for
             exec_startup RPCs from any tasks we already started?  */
@@ -100,9 +100,9 @@ deadboot (void *p)
            exit (0);
          ports_enable_class (execboot_portclass);
        }
-      ports_enable_class (trivfs_protid_portclasses[0]);
+      ports_enable_class (trivfs_protid_class);
     }
-  ports_enable_class (trivfs_cntl_portclasses[0]);
+  ports_enable_class (trivfs_control_class);
 }
 
 #define OPT_DEVICE_MASTER_PORT (-1)
@@ -214,15 +214,29 @@ main (int argc, char **argv)
      S_exec_init (below).  */
   procserver = getproc ();
 
-  port_bucket = ports_create_bucket ();
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
+  err = trivfs_add_port_bucket (&port_bucket);
+  if (err)
+    error (1, 0, "error creating port bucket");
+
+  err = trivfs_add_control_port_class (&trivfs_control_class);
+  if (err)
+    error (1, 0, "error creating control port class");
+
+  err = trivfs_add_protid_port_class (&trivfs_protid_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
+
   execboot_portclass = ports_create_class (deadboot, NULL);
 
   /* Reply to our parent.  */
   err = trivfs_startup (bootstrap, 0,
-                       trivfs_cntl_portclasses[0], port_bucket,
-                       trivfs_protid_portclasses[0], port_bucket,
+                        trivfs_control_class, port_bucket,
+                        trivfs_protid_class, port_bucket, &fsys);
+
+  /* Reply to our parent.  */
+  err = trivfs_startup (bootstrap, 0,
+                       trivfs_control_class, port_bucket,
+                       trivfs_protid_class, port_bucket,
                        &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
@@ -248,11 +262,11 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   int count;
 
   /* Stop new requests.  */
-  ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-  ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+  ports_inhibit_class_rpcs (trivfs_control_class);
+  ports_inhibit_class_rpcs (trivfs_protid_class);
 
   /* Are there any extant user ports for the /servers/exec file?  */
-  count = ports_count_class (trivfs_protid_portclasses[0]);
+  count = ports_count_class (trivfs_protid_class);
   if (count == 0 || (flags & FSYS_GOAWAY_FORCE))
     {
       /* No users.  Disconnect from the filesystem.  */
@@ -275,9 +289,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   else
     {
       /* We won't go away, so start things going again...  */
-      ports_enable_class (trivfs_protid_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+      ports_enable_class (trivfs_protid_class);
+      ports_resume_class_rpcs (trivfs_control_class);
+      ports_resume_class_rpcs (trivfs_protid_class);
 
       return EBUSY;
     }
diff --git a/libddekit/memory.c b/libddekit/memory.c
index 34b283b..6602ea3 100644
--- a/libddekit/memory.c
+++ b/libddekit/memory.c
@@ -25,7 +25,7 @@
 #include "ddekit/panic.h"
 #include "ddekit/pgtab.h"
 
-#define CACHE_LINE_SIZE 32
+#define CACHE_LINE_SIZE        64
 
 /****************
  ** Page cache **
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index d10d783..731d8c6 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -279,6 +279,7 @@ diskfs_start_bootstrap ()
   if (_diskfs_boot_pause)
     {
       printf ("pausing for %s...\n", exec_argv);
+      fflush (stdout);
       getc (stdin);
     }
   printf (" %s", basename (exec_argv));
@@ -637,15 +638,19 @@ start_execserver (void)
   assert_perror (err);
   right = ports_get_send_right (execboot_info);
   ports_port_deref (execboot_info);
-  task_set_special_port (diskfs_exec_server_task, TASK_BOOTSTRAP_PORT, right);
-  mach_port_deallocate (mach_task_self (), right);
+  err = task_set_special_port (diskfs_exec_server_task, TASK_BOOTSTRAP_PORT, 
right);
+  assert_perror (err);
+  err = mach_port_deallocate (mach_task_self (), right);
+  assert_perror (err);
 
   if (_diskfs_boot_pause)
     {
       printf ("pausing for exec\n");
+      fflush (stdout);
       getc (stdin);
     }
-  task_resume (diskfs_exec_server_task);
+  err = task_resume (diskfs_exec_server_task);
+  assert_perror (err);
 
   printf (" exec");
   fflush (stdout);
diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c
index 7d69a2a..3c0578f 100644
--- a/libmachdev/trivfs_server.c
+++ b/libmachdev/trivfs_server.c
@@ -19,10 +19,9 @@ int trivfs_support_write = 0;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = O_READ | O_WRITE;
 
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
+/* Our port classes.  */
+struct port_class *trivfs_protid_class;
+struct port_class *trivfs_cntl_class;
 
 /* Implementation of notify interface */
 kern_return_t
@@ -70,7 +69,7 @@ boolean_t
 is_master_device (mach_port_t port)
 {
   struct port_info *pi = ports_lookup_port (port_bucket, port,
-                                           trivfs_protid_portclasses[0]);
+                                           trivfs_protid_class);
   if (pi == NULL)
     return FALSE;
   
@@ -96,8 +95,8 @@ trivfs_append_args (struct trivfs_control *fsys, char **argz, 
size_t *argz_len)
 int trivfs_init()
 {
   port_bucket = ports_create_bucket ();
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
+  trivfs_cntl_class = ports_create_class (trivfs_clean_cntl, 0);
+  trivfs_protid_class = ports_create_class (trivfs_clean_protid, 0);
   return 0;
 }
 
@@ -107,17 +106,17 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   int count;
 
   /* Stop new requests.  */
-  ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-  ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+  ports_inhibit_class_rpcs (trivfs_cntl_class);
+  ports_inhibit_class_rpcs (trivfs_protid_class);
 
-  count = ports_count_class (trivfs_protid_portclasses[0]);
+  count = ports_count_class (trivfs_protid_class);
 
   if (count && !(flags & FSYS_GOAWAY_FORCE))
     {
       /* We won't go away, so start things going again...  */
-      ports_enable_class (trivfs_protid_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+      ports_enable_class (trivfs_protid_class);
+      ports_resume_class_rpcs (trivfs_cntl_class);
+      ports_resume_class_rpcs (trivfs_protid_class);
       return EBUSY;
     }
 
@@ -158,8 +157,8 @@ void trivfs_server()
 
   /* Reply to our parent.  */
   err = trivfs_startup (bootstrap, 0,
-                       trivfs_cntl_portclasses[0], port_bucket,
-                       trivfs_protid_portclasses[0], port_bucket, &fsys);
+                       trivfs_cntl_class, port_bucket,
+                       trivfs_protid_class, port_bucket, &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (1, err, "Contacting parent");
diff --git a/libnetfs/io-reauthenticate.c b/libnetfs/io-reauthenticate.c
index f4f50d5..8ff4182 100644
--- a/libnetfs/io-reauthenticate.c
+++ b/libnetfs/io-reauthenticate.c
@@ -31,8 +31,18 @@ netfs_S_io_reauthenticate (struct protid *user, mach_port_t 
rend_port)
   if (!user)
     return EOPNOTSUPP;
 
+  /* This routine must carefully ignore EINTR because we
+     are a simpleroutine, so callers won't know to restart. */
+
   pthread_mutex_lock (&user->po->np->lock);
-  newpi = netfs_make_protid (user->po, 0);
+  do
+    newpi = netfs_make_protid (user->po, 0);
+  while (! newpi && errno == EINTR);
+  if (! newpi)
+    {
+      pthread_mutex_unlock (&user->po->np->lock);
+      return errno;
+    }
 
   newright = ports_get_send_right (newpi);
   assert (newright != MACH_PORT_NULL);
@@ -43,7 +53,8 @@ netfs_S_io_reauthenticate (struct protid *user, mach_port_t 
rend_port)
                       newright, 1);
   pthread_mutex_lock (&user->po->np->lock);
 
-  mach_port_deallocate (mach_task_self (), rend_port);
+  if (!err)
+    mach_port_deallocate (mach_task_self (), rend_port);
   mach_port_deallocate (mach_task_self (), newright);
 
   mach_port_move_member (mach_task_self (), newpi->pi.port_right,
diff --git a/libports/inhibit-all-rpcs.c b/libports/inhibit-all-rpcs.c
index 27e2ec5..71aecf1 100644
--- a/libports/inhibit-all-rpcs.c
+++ b/libports/inhibit-all-rpcs.c
@@ -33,7 +33,6 @@ ports_inhibit_all_rpcs ()
     err = EBUSY;
   else
     {
-      struct port_bucket *bucket;
       int this_one = 0;
 
       pthread_rwlock_rdlock (&_ports_htable_lock);
diff --git a/libports/inhibit-class-rpcs.c b/libports/inhibit-class-rpcs.c
index 9a87a5f..ed99aad 100644
--- a/libports/inhibit-class-rpcs.c
+++ b/libports/inhibit-class-rpcs.c
@@ -32,8 +32,6 @@ ports_inhibit_class_rpcs (struct port_class *class)
     err = EBUSY;
   else
     {
-      struct port_info *pi;
-      struct rpc_info *rpc;
       int this_one = 0;
 
       pthread_rwlock_rdlock (&_ports_htable_lock);
diff --git a/libshouldbeinlibc/idvec-rep.c b/libshouldbeinlibc/idvec-rep.c
index 16408a4..4fc7712 100644
--- a/libshouldbeinlibc/idvec-rep.c
+++ b/libshouldbeinlibc/idvec-rep.c
@@ -129,7 +129,7 @@ lookup_uid (uid_t uid)
 {
   char buf[1024];
   struct passwd _pw, *pw;
-  if (getpwuid_r (uid, &_pw, buf, sizeof buf, &pw) == 0)
+  if (getpwuid_r (uid, &_pw, buf, sizeof buf, &pw) == 0 && pw)
     return strdup (pw->pw_name);
   else
     return 0;
@@ -141,7 +141,7 @@ lookup_gid (gid_t gid)
 {
   char buf[1024];
   struct group _gr, *gr;
-  if (getgrgid_r (gid, &_gr, buf, sizeof buf, &gr) == 0)
+  if (getgrgid_r (gid, &_gr, buf, sizeof buf, &gr) == 0 && gr)
     return strdup (gr->gr_name);
   else
     return 0;
diff --git a/libshouldbeinlibc/idvec-verify.c b/libshouldbeinlibc/idvec-verify.c
index 4d9b6db..4019a04 100644
--- a/libshouldbeinlibc/idvec-verify.c
+++ b/libshouldbeinlibc/idvec-verify.c
@@ -107,7 +107,8 @@ verify_passwd (const char *password,
          return pw->pw_passwd;
        }
 
-      if (getpwuid_r (wheel_uid, &_pw, lookup_buf, sizeof lookup_buf, &pw))
+      if (getpwuid_r (wheel_uid, &_pw, lookup_buf, sizeof lookup_buf, &pw)
+         || ! pw)
        return errno ?: EINVAL;
 
       sys_encrypted = check_shadow (pw);
@@ -266,7 +267,7 @@ verify_id (uid_t id, int is_group, int multiple,
          {
            struct group _gr, *gr;
            if (getgrgid_r (id, &_gr, id_lookup_buf, sizeof id_lookup_buf, &gr)
-               == 0)
+               == 0 && gr)
              {
                if (!gr->gr_passwd || !*gr->gr_passwd)
                  return (*verify_fn) ("", id, 1, gr, verify_hook);
@@ -278,7 +279,7 @@ verify_id (uid_t id, int is_group, int multiple,
          {
            struct passwd _pw, *pw;
            if (getpwuid_r (id, &_pw, id_lookup_buf, sizeof id_lookup_buf, &pw)
-               == 0)
+               == 0 && pw)
              {
                if (strcmp (pw->pw_passwd, SHADOW_PASSWORD_STRING) == 0)
                  {
diff --git a/libtrivfs/io-reauthenticate.c b/libtrivfs/io-reauthenticate.c
index c75f5fc..35775e5 100644
--- a/libtrivfs/io-reauthenticate.c
+++ b/libtrivfs/io-reauthenticate.c
@@ -52,7 +52,8 @@ trivfs_S_io_reauthenticate (struct trivfs_protid *cred,
   assert (newright != MACH_PORT_NULL);
 
   err = iohelp_reauth (&newcred->user, auth, rendport, newright, 1);
-  mach_port_deallocate (mach_task_self (), rendport);
+  if (!err)
+    mach_port_deallocate (mach_task_self (), rendport);
   mach_port_deallocate (mach_task_self (), auth);
   if (err)
     return err;
diff --git a/libtrivfs/mig-decls.h b/libtrivfs/mig-decls.h
index 13a9eb7..1909199 100644
--- a/libtrivfs/mig-decls.h
+++ b/libtrivfs/mig-decls.h
@@ -37,57 +37,41 @@ extern size_t trivfs_num_dynamic_port_buckets;
 static inline struct trivfs_protid * __attribute__ ((unused))
 trivfs_begin_using_protid (mach_port_t port)
 {
-  if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1)
+  struct port_info *pi = ports_lookup_port (0, port, 0);
+
+  if (pi)
     {
-      struct port_info *pi = ports_lookup_port (0, port, 0);
-      int i;
-
-      if (pi)
-       {
-         for (i = 0; i < trivfs_protid_nportclasses; i++)
-           if (pi->class == trivfs_protid_portclasses[i])
-             return (struct trivfs_protid *) pi;
-         for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++)
-           if (pi->class == trivfs_dynamic_protid_port_classes[i])
-             return (struct trivfs_protid *) pi;
-         ports_port_deref (pi);
-       }
-
-      return 0;
+      size_t i;
+      for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++)
+       if (pi->class == trivfs_dynamic_protid_port_classes[i])
+         return (struct trivfs_protid *) pi;
+      for (i = 0; i < trivfs_protid_nportclasses; i++)
+       if (pi->class == trivfs_protid_portclasses[i])
+         return (struct trivfs_protid *) pi;
+      ports_port_deref (pi);
     }
-  else if (trivfs_protid_nportclasses == 1)
-    return ports_lookup_port (0, port, trivfs_protid_portclasses[0]);
-  else
-    return ports_lookup_port (0, port, trivfs_dynamic_protid_port_classes[0]);
+
+  return NULL;
 }
 
 static inline struct trivfs_protid * __attribute__ ((unused))
 trivfs_begin_using_protid_payload (unsigned long payload)
 {
-  if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1)
+  struct port_info *pi = ports_lookup_payload (NULL, payload, NULL);
+
+  if (pi)
     {
-      struct port_info *pi = ports_lookup_payload (NULL, payload, NULL);
-      int i;
-
-      if (pi)
-       {
-         for (i = 0; i < trivfs_protid_nportclasses; i++)
-           if (pi->class == trivfs_protid_portclasses[i])
-             return (struct trivfs_protid *) pi;
-         for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++)
-           if (pi->class == trivfs_dynamic_protid_port_classes[i])
-             return (struct trivfs_protid *) pi;
-         ports_port_deref (pi);
-       }
-
-      return NULL;
+      size_t i;
+      for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++)
+       if (pi->class == trivfs_dynamic_protid_port_classes[i])
+         return (struct trivfs_protid *) pi;
+      for (i = 0; i < trivfs_protid_nportclasses; i++)
+       if (pi->class == trivfs_protid_portclasses[i])
+         return (struct trivfs_protid *) pi;
+      ports_port_deref (pi);
     }
-  else if (trivfs_protid_nportclasses == 1)
-    return ports_lookup_payload (NULL, payload,
-                                trivfs_protid_portclasses[0]);
-  else
-    return ports_lookup_payload (NULL, payload,
-                                trivfs_dynamic_protid_port_classes[0]);
+
+  return NULL;
 }
 
 static inline void __attribute__ ((unused))
@@ -100,57 +84,41 @@ trivfs_end_using_protid (struct trivfs_protid *cred)
 static inline struct trivfs_control * __attribute__ ((unused))
 trivfs_begin_using_control (mach_port_t port)
 {
-  if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1)
+  struct port_info *pi = ports_lookup_port (0, port, 0);
+
+  if (pi)
     {
-      struct port_info *pi = ports_lookup_port (0, port, 0);
-      int i;
-
-      if (pi)
-       {
-         for (i = 0; i < trivfs_cntl_nportclasses; i++)
-           if (pi->class == trivfs_cntl_portclasses[i])
-             return (struct trivfs_control *) pi;
-         for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++)
-           if (pi->class == trivfs_dynamic_control_port_classes[i])
-             return (struct trivfs_control *) pi;
-         ports_port_deref (pi);
-       }
-
-      return 0;
+      size_t i;
+      for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++)
+       if (pi->class == trivfs_dynamic_control_port_classes[i])
+         return (struct trivfs_control *) pi;
+      for (i = 0; i < trivfs_cntl_nportclasses; i++)
+       if (pi->class == trivfs_cntl_portclasses[i])
+         return (struct trivfs_control *) pi;
+      ports_port_deref (pi);
     }
-  else if (trivfs_cntl_nportclasses == 1)
-    return ports_lookup_port (0, port, trivfs_cntl_portclasses[0]);
-  else
-    return ports_lookup_port (0, port, trivfs_dynamic_control_port_classes[0]);
+
+  return NULL;
 }
 
 static inline struct trivfs_control * __attribute__ ((unused))
 trivfs_begin_using_control_payload (unsigned long payload)
 {
-  if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1)
+  struct port_info *pi = ports_lookup_payload (NULL, payload, NULL);
+
+  if (pi)
     {
-      struct port_info *pi = ports_lookup_payload (NULL, payload, NULL);
-      int i;
-
-      if (pi)
-       {
-         for (i = 0; i < trivfs_cntl_nportclasses; i++)
-           if (pi->class == trivfs_cntl_portclasses[i])
-             return (struct trivfs_control *) pi;
-         for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++)
-           if (pi->class == trivfs_dynamic_control_port_classes[i])
-             return (struct trivfs_control *) pi;
-         ports_port_deref (pi);
-       }
-
-      return NULL;
+      size_t i;
+      for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++)
+       if (pi->class == trivfs_dynamic_control_port_classes[i])
+         return (struct trivfs_control *) pi;
+      for (i = 0; i < trivfs_cntl_nportclasses; i++)
+       if (pi->class == trivfs_cntl_portclasses[i])
+         return (struct trivfs_control *) pi;
+      ports_port_deref (pi);
     }
-  else if (trivfs_cntl_nportclasses == 1)
-    return ports_lookup_payload (NULL, payload,
-                                trivfs_cntl_portclasses[0]);
-  else
-    return ports_lookup_payload (NULL, payload,
-                                trivfs_dynamic_control_port_classes[0]);
+
+  return NULL;
 }
 
 static inline void __attribute__ ((unused))
diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h
index 8902338..d620a7b 100644
--- a/libtrivfs/trivfs.h
+++ b/libtrivfs/trivfs.h
@@ -79,10 +79,13 @@ extern int trivfs_allow_open;
    pointers for passing to rpcs, in addition to those passed to or created by
    trivfs_create_control (or trivfs_startup) will automatically be
    recognized.  */
-extern struct port_class *trivfs_protid_portclasses[];
-extern int trivfs_protid_nportclasses;
-extern struct port_class *trivfs_cntl_portclasses[];
-extern int trivfs_cntl_nportclasses;
+/* Deprecation notice: The use of these vectors is deprecated.  Please
+   use the dynamic class support.  These vectors will be removed in
+   Hurd 0.8.  */
+extern struct port_class *trivfs_protid_portclasses[] __attribute__ 
((deprecated));
+extern int trivfs_protid_nportclasses __attribute__ ((deprecated));
+extern struct port_class *trivfs_cntl_portclasses[] __attribute__ 
((deprecated));
+extern int trivfs_cntl_nportclasses __attribute__ ((deprecated));
 
 /* The user must define this function.  This should modify a struct
    stat (as returned from the underlying node) for presentation to
diff --git a/pfinet/main.c b/pfinet/main.c
index 8716fdb..46457a9 100644
--- a/pfinet/main.c
+++ b/pfinet/main.c
@@ -56,11 +56,9 @@ int trivfs_support_write = 1;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = O_READ | O_WRITE;
 
-struct port_class *trivfs_protid_portclasses[2];
-int trivfs_protid_nportclasses = 2;
-
-struct port_class *trivfs_cntl_portclasses[2];
-int trivfs_cntl_nportclasses = 2;
+/* We have a class each per portclass.  */
+struct port_class *pfinet_protid_portclasses[2];
+struct port_class *pfinet_cntl_portclasses[2];
 
 /* Which portclass to install on the bootstrap port, default to IPv4. */
 int pfinet_bootstrap_portclass = PORTCLASS_INET;
@@ -334,7 +332,7 @@ main (int argc,
 
   if (bootstrap != MACH_PORT_NULL) {
     /* Create portclass to install on the bootstrap port. */
-    if(trivfs_protid_portclasses[pfinet_bootstrap_portclass]
+    if(pfinet_protid_portclasses[pfinet_bootstrap_portclass]
        != MACH_PORT_NULL)
       error(1, 0, "No portclass left to assign to bootstrap port");
 
@@ -342,17 +340,23 @@ main (int argc,
     if (pfinet_bootstrap_portclass == PORTCLASS_INET6)
       pfinet_activate_ipv6 ();
 #endif
-    
-    trivfs_protid_portclasses[pfinet_bootstrap_portclass] =
-      ports_create_class (trivfs_clean_protid, 0);
-    trivfs_cntl_portclasses[pfinet_bootstrap_portclass] =
-      ports_create_class (trivfs_clean_cntl, 0);
+
+    err = trivfs_add_protid_port_class (
+       &pfinet_protid_portclasses[pfinet_bootstrap_portclass]);
+    if (err)
+      error (1, 0, "error creating control port class");
+
+    err = trivfs_add_control_port_class (
+       &pfinet_cntl_portclasses[pfinet_bootstrap_portclass]);
+    if (err)
+      error (1, 0, "error creating control port class");
 
     /* Talk to parent and link us in.  */
     err = trivfs_startup (bootstrap, 0,
-                         trivfs_cntl_portclasses[pfinet_bootstrap_portclass],
-                         pfinet_bucket, trivfs_protid_portclasses
-                         [pfinet_bootstrap_portclass], pfinet_bucket, 
+                         pfinet_cntl_portclasses[pfinet_bootstrap_portclass],
+                         pfinet_bucket,
+                          
pfinet_protid_portclasses[pfinet_bootstrap_portclass],
+                          pfinet_bucket,
                          &pfinetctl);
 
     if (err)
@@ -371,7 +375,7 @@ main (int argc,
     /* Check that at least one portclass has been bound, 
        error out otherwise. */
     for (i = 0; i < trivfs_protid_nportclasses; i ++)
-      if (trivfs_protid_portclasses[i] != MACH_PORT_NULL)
+      if (pfinet_protid_portclasses[i] != MACH_PORT_NULL)
        break;
 
     if (i == trivfs_protid_nportclasses)
@@ -424,22 +428,25 @@ pfinet_bind (int portclass, const char *name)
     err = errno;
 
   if (! err) {
-    if (trivfs_protid_portclasses[portclass] != MACH_PORT_NULL)
+    if (pfinet_protid_portclasses[portclass] != MACH_PORT_NULL)
       error (1, 0, "Cannot bind one protocol to multiple nodes.\n");
 
 #ifdef CONFIG_IPV6
     if (portclass == PORTCLASS_INET6)
       pfinet_activate_ipv6 ();
 #endif
+    //mark
+    err = trivfs_add_protid_port_class (&pfinet_protid_portclasses[portclass]);
+    if (err)
+      error (1, 0, "error creating control port class");
 
-    trivfs_protid_portclasses[portclass] =
-      ports_create_class (trivfs_clean_protid, 0);
-    trivfs_cntl_portclasses[portclass] =
-      ports_create_class (trivfs_clean_cntl, 0);
+    err = trivfs_add_control_port_class (&pfinet_cntl_portclasses[portclass]);
+    if (err)
+      error (1, 0, "error creating control port class");
 
-    err = trivfs_create_control (file, trivfs_cntl_portclasses[portclass],
-                                pfinet_bucket, 
-                                trivfs_protid_portclasses[portclass], 
+    err = trivfs_create_control (file, pfinet_cntl_portclasses[portclass],
+                                pfinet_bucket,
+                                pfinet_protid_portclasses[portclass],
                                 pfinet_bucket, &cntl);
   }
 
@@ -473,16 +480,16 @@ trivfs_goaway (struct trivfs_control *cntl, int flags)
   else
     {
       /* Stop new requests.  */
-      ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+      ports_inhibit_class_rpcs (pfinet_cntl_portclasses[0]);
+      ports_inhibit_class_rpcs (pfinet_protid_portclasses[0]);
       ports_inhibit_class_rpcs (socketport_class);
 
       if (ports_count_class (socketport_class) != 0)
        {
          /* We won't go away, so start things going again...  */
          ports_enable_class (socketport_class);
-         ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-         ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+         ports_resume_class_rpcs (pfinet_cntl_portclasses[0]);
+         ports_resume_class_rpcs (pfinet_protid_portclasses[0]);
 
          return EBUSY;
        }
diff --git a/pfinet/options.c b/pfinet/options.c
index daffcd5..ae44759 100644
--- a/pfinet/options.c
+++ b/pfinet/options.c
@@ -133,7 +133,7 @@ parse_interface_copy_device(struct device *src,
       && FIB_RES_GW(res) != INADDR_ANY)
     dst->gateway = FIB_RES_GW (res);
 #ifdef CONFIG_IPV6
-  if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL)
+  if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL)
     idev = ipv6_find_idev(src);
 
   if (idev)
@@ -452,7 +452,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
        {
 #ifdef CONFIG_IPV6
          struct inet6_dev *idev = NULL;
-         if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL
+         if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL
              && in->device)
            idev = ipv6_find_idev(in->device);
 #endif
@@ -570,7 +570,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
 
       /* Set IPv6 default router. */
 #ifdef CONFIG_IPV6
-      if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL)
+      if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL)
        {
          struct rt6_info *rt6i = ipv6_get_dflt_router ();
 
@@ -710,7 +710,7 @@ trivfs_append_args (struct trivfs_control *fsys, char 
**argz, size_t *argz_len)
 #ifdef CONFIG_IPV6
       struct inet6_dev *idev = NULL;
 
-      if (trivfs_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL)
+      if (pfinet_protid_portclasses[PORTCLASS_INET6] != MACH_PORT_NULL)
        idev = ipv6_find_idev(dev);
 
       if (idev)
diff --git a/pfinet/pfinet.h b/pfinet/pfinet.h
index 46aa97b..6e59225 100644
--- a/pfinet/pfinet.h
+++ b/pfinet/pfinet.h
@@ -92,11 +92,8 @@ enum {
   PORTCLASS_INET6,
 };
 
-extern struct port_class *trivfs_protid_portclasses[];
-extern int trivfs_protid_nportclasses;
-
-extern struct port_class *trivfs_cntl_portclasses[2];
-extern int trivfs_cntl_nportclasses;
+extern struct port_class *pfinet_protid_portclasses[2];
+extern struct port_class *pfinet_cntl_portclasses[2];
 
 /* Which portclass to install on the bootstrap port. */
 extern int pfinet_bootstrap_portclass;
diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c
index 3f8b7fb..14b3120 100644
--- a/pfinet/socket-ops.c
+++ b/pfinet/socket-ops.c
@@ -82,7 +82,7 @@ S_socket_create (struct trivfs_protid *master,
        isroot = 1;
     }
 
-  if (master->pi.class == trivfs_protid_portclasses[PORTCLASS_INET])
+  if (master->pi.class == pfinet_protid_portclasses[PORTCLASS_INET])
     err = - (*net_families[PF_INET]->create) (sock, protocol);
   else
     err = - (*net_families[PF_INET6]->create) (sock, protocol);
diff --git a/pflocal/pflocal.c b/pflocal/pflocal.c
index fcb62d1..07d1a97 100644
--- a/pflocal/pflocal.c
+++ b/pflocal/pflocal.c
@@ -38,12 +38,6 @@ int trivfs_support_read = 0;
 int trivfs_support_write = 0;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = 0;
-
-/* Trivfs noise.  */
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
 
 /* ---------------------------------------------------------------- */
 #include "socket_S.h"
@@ -70,6 +64,7 @@ main(int argc, char *argv[])
 {
   error_t err;
   mach_port_t bootstrap;
+  struct trivfs_control *fsys;
 
   if (argc > 1)
     {
@@ -81,25 +76,18 @@ main(int argc, char *argv[])
   if (bootstrap == MACH_PORT_NULL)
     error(2, 0, "Must be started as a translator");
 
-  pf_port_bucket = ports_create_bucket ();
-
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
-
   /* Prepare to create sockets.  */
   err = sock_global_init ();
   if (err)
     error(3, err, "Initializing");
 
   /* Reply to our parent */
-  err =
-    trivfs_startup (bootstrap, 0,
-                   trivfs_cntl_portclasses[0], pf_port_bucket,
-                   trivfs_protid_portclasses[0], pf_port_bucket,
-                   NULL);
+  err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
   if (err)
     error(3, err, "Contacting parent");
 
+  pf_port_bucket = fsys->pi.bucket;
+
   /* Launch. */
   do
     ports_manage_port_operations_multithread (pf_port_bucket,
diff --git a/trans/crash.c b/trans/crash.c
index c424b16..23f2a2d 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -44,6 +44,10 @@ process_t procserver;                /* Our proc port, for 
easy access.  */
 /* Port bucket we service requests on.  */
 struct port_bucket *port_bucket;
 
+/* Our port classes.  */
+struct port_class *trivfs_control_class;
+struct port_class *trivfs_protid_class;
+
 /* Trivfs hooks.  */
 int trivfs_fstype = FSTYPE_MISC;
 int trivfs_fsid = 0;
@@ -52,11 +56,6 @@ int trivfs_support_write = 0;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = O_READ|O_WRITE|O_EXEC;
 
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
-
 struct trivfs_control *fsys;
 
 enum crash_action
@@ -156,7 +155,7 @@ S_crash_dump_task (mach_port_t port,
   mach_port_t user_proc = MACH_PORT_NULL;
   enum crash_action how;
 
-  cred = ports_lookup_port (port_bucket, port, trivfs_protid_portclasses[0]);
+  cred = ports_lookup_port (port_bucket, port, trivfs_protid_class);
   if (! cred)
     return EOPNOTSUPP;
 
@@ -415,11 +414,11 @@ dead_crasher (void *ptr)
   /* The port data structures are cleaned up when we return.  */
 
   /* See if we are going away and this was the last thing keeping us up.  */
-  if (ports_count_class (trivfs_cntl_portclasses[0]) == 0)
+  if (ports_count_class (trivfs_control_class) == 0)
     {
       /* We have no fsys control port, so we are detached from the
         parent filesystem.  Maybe we have no users left either.  */
-      if (ports_count_class (trivfs_protid_portclasses[0]) == 0)
+      if (ports_count_class (trivfs_protid_class) == 0)
        {
          /* We have no user ports left.  Maybe we have no crashers still
             around either.  */
@@ -428,9 +427,9 @@ dead_crasher (void *ptr)
            exit (0);
          ports_enable_class (crasher_portclass);
        }
-      ports_enable_class (trivfs_protid_portclasses[0]);
+      ports_enable_class (trivfs_protid_class);
     }
-  ports_enable_class (trivfs_cntl_portclasses[0]);
+  ports_enable_class (trivfs_control_class);
 }
 
 
@@ -563,20 +562,27 @@ main (int argc, char **argv)
   /* Fetch our proc server port for easy use.  */
   procserver = getproc ();
 
-  port_bucket = ports_create_bucket ();
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
   crasher_portclass = ports_create_class (dead_crasher, 0);
 
+  err = trivfs_add_control_port_class (&trivfs_control_class);
+  if (err)
+    error (1, 0, "error creating control port class");
+
+  err = trivfs_add_protid_port_class (&trivfs_protid_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
+
   /* Reply to our parent.  */
   err = trivfs_startup (bootstrap, 0,
-                       trivfs_cntl_portclasses[0], port_bucket,
-                       trivfs_protid_portclasses[0], port_bucket,
-                       &fsys);
+                        trivfs_control_class, NULL,
+                        trivfs_protid_class, NULL, &fsys);
+
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (3, err, "Contacting parent");
 
+  port_bucket = fsys->pi.bucket;
+
   /* Launch.  */
   do
     ports_manage_port_operations_multithread (port_bucket, crash_demuxer,
@@ -602,11 +608,11 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   int count;
 
   /* Stop new requests.  */
-  ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-  ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+  ports_inhibit_class_rpcs (trivfs_control_class);
+  ports_inhibit_class_rpcs (trivfs_protid_class);
 
   /* Are there any extant user ports for the /servers/crash file?  */
-  count = ports_count_class (trivfs_protid_portclasses[0]);
+  count = ports_count_class (trivfs_protid_class);
   if (count == 0 || (flags & FSYS_GOAWAY_FORCE))
     {
       /* No users.  Disconnect from the filesystem.  */
@@ -629,9 +635,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   else
     {
       /* We won't go away, so start things going again...  */
-      ports_enable_class (trivfs_protid_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+      ports_enable_class (trivfs_protid_class);
+      ports_resume_class_rpcs (trivfs_control_class);
+      ports_resume_class_rpcs (trivfs_protid_class);
 
       return EBUSY;
     }
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 76fc901..6962810 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -247,6 +247,17 @@ check_openmodes (struct netnode *nn, int newmodes, file_t 
file)
   return err;
 }
 
+/* Return the mode that the real underlying file should have if the
+   fake mode is being set to MODE.  We always give ourselves read and
+   write permission so that we can open the file as root would be able
+   to.  We give ourselves execute permission iff any execute bit is
+   set in the fake mode.  */
+static inline mode_t
+real_from_fake_mode (mode_t mode)
+{
+  return mode | S_IREAD | S_IWRITE | (((mode << 3) | (mode << 6)) & S_IEXEC);
+}
+
 /* This is called by netfs_S_fsys_getroot.  */
 error_t
 netfs_check_open_permissions (struct iouser *user, struct node *np,
@@ -283,7 +294,7 @@ netfs_S_dir_lookup (struct protid *diruser,
  redo_lookup:
   err = dir_lookup (dir, filename,
                    flags & (O_NOLINK|O_RDWR|O_EXEC|O_CREAT|O_EXCL|O_NONBLOCK),
-                   mode, do_retry, retry_name, &file);
+                   real_from_fake_mode (mode), do_retry, retry_name, &file);
   if (dir != netfs_node_netnode (dnp)->file)
     mach_port_deallocate (mach_task_self (), dir);
   if (err)
@@ -525,17 +536,6 @@ netfs_attempt_chauthor (struct iouser *cred, struct node 
*np, uid_t author)
   return 0;
 }
 
-/* Return the mode that the real underlying file should have if the
-   fake mode is being set to MODE.  We always give ourselves read and
-   write permission so that we can open the file as root would be able
-   to.  We give ourselves execute permission iff any execute bit is
-   set in the fake mode.  */
-static inline mode_t
-real_from_fake_mode (mode_t mode)
-{
-  return mode | S_IREAD | S_IWRITE | (((mode << 3) | (mode << 6)) & S_IEXEC);
-}
-
 /* This should attempt a chmod call for the user specified by CRED on
    locked node NODE, to change the mode to MODE.  Unlike the normal Unix
    and Hurd meaning of chmod, this function is also used to attempt to
diff --git a/trans/ifsock.c b/trans/ifsock.c
index af2376a..13a2133 100644
--- a/trans/ifsock.c
+++ b/trans/ifsock.c
@@ -59,11 +59,6 @@ int trivfs_support_exec = 0;
 
 int trivfs_allow_open = 0;
 
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
-
 int
 demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
 {
@@ -85,8 +80,6 @@ main (int argc, char **argv)
   control_class = ports_create_class (trivfs_clean_cntl, 0);
   node_class = ports_create_class (trivfs_clean_protid, 0);
   port_bucket = ports_create_bucket ();
-  trivfs_protid_portclasses[0] = node_class;
-  trivfs_cntl_portclasses[0] = control_class;
 
   task_get_bootstrap_port (mach_task_self (), &bootstrap);
   if (bootstrap == MACH_PORT_NULL)
diff --git a/trans/magic.c b/trans/magic.c
index 5808483..a033db9 100644
--- a/trans/magic.c
+++ b/trans/magic.c
@@ -74,6 +74,9 @@ static struct trivfs_control *all_fsys;
 
 /* Trivfs hooks  */
 
+/* Our port class.  */
+struct port_class *trivfs_protid_class;
+
 int trivfs_fstype = FSTYPE_DEV;
 int trivfs_fsid = 0;
 
@@ -480,8 +483,12 @@ main (int argc, char **argv)
   if (m->directory)
     trivfs_peropen_destroy_hook = &magic_peropen_destroy;
 
+  err = trivfs_add_protid_port_class (&trivfs_protid_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
+
   /* Reply to our parent */
-  err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
+  err = trivfs_startup (bootstrap, 0, 0, 0, trivfs_protid_class, 0, &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (3, err, "Contacting parent");
@@ -521,8 +528,7 @@ trivfs_S_fsys_forward (mach_port_t server,
                       char *argz, size_t argz_len)
 {
   struct trivfs_protid *cred
-    = ports_lookup_port (all_fsys->pi.bucket, server,
-                        trivfs_protid_portclasses[0]);
+    = ports_lookup_port (all_fsys->pi.bucket, server, trivfs_protid_class);
   if (!cred)
     return EOPNOTSUPP;
   ports_port_deref (cred);
@@ -547,8 +553,8 @@ trivfs_S_fsys_forward (mach_port_t server,
   /* Now we are ready to start up the filesystem.  Contact the parent.  */
   struct trivfs_control *fsys;
   err = trivfs_startup (requestor, 0,
-                       trivfs_cntl_portclasses[0], all_fsys->pi.bucket,
-                       trivfs_protid_portclasses[0], all_fsys->pi.bucket,
+                       NULL, all_fsys->pi.bucket,
+                       NULL, all_fsys->pi.bucket,
                        &fsys);
   if (err)
     {
diff --git a/trans/new-fifo.c b/trans/new-fifo.c
index e71c95c..0ceb842 100644
--- a/trans/new-fifo.c
+++ b/trans/new-fifo.c
@@ -176,13 +176,6 @@ fifo_trans_parse_args (struct fifo_trans *trans, int argc, 
char **argv,
   return argp_parse (&argp, argc, argv, print_errs ? 0 : ARGP_SILENT, 0, 0);
 }
 
-/* ---------------------------------------------------------------- */
-
-struct port_class *trivfs_protid_portclasses[2];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 2;
-int trivfs_cntl_nportclasses = 1;
-
 int
 main (int argc, char **argv)
 {
@@ -215,14 +208,21 @@ main (int argc, char **argv)
        exit (0);
     }
 
-  port_bucket = ports_create_bucket ();
-  fifo_port_class =  ports_create_class (trivfs_clean_protid, 0);
-  server_port_class =  ports_create_class (trivfs_clean_protid, 0);
-  fsys_port_class = ports_create_class (clean_fsys, 0);
+  err = trivfs_add_port_bucket (&port_bucket);
+  if (err)
+    error (1, 0, "error creating port bucket");
+
+  err = trivfs_add_control_port_class (&fsys_port_class);
+  if (err)
+    error (1, 0, "error creating control port class");
+
+  err = trivfs_add_protid_port_class (&fifo_port_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
 
-  trivfs_protid_portclasses[0] = fifo_port_class;
-  trivfs_protid_portclasses[1] = server_port_class;
-  trivfs_cntl_portclasses[0] = fsys_port_class;
+    err = trivfs_add_protid_port_class (&server_port_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
 
   /* Reply to our parent */
   fifo_trans_start (trans, bootstrap);
diff --git a/trans/password.c b/trans/password.c
index 344b78b..9ffcaa0 100644
--- a/trans/password.c
+++ b/trans/password.c
@@ -39,6 +39,10 @@ const char *argp_program_version = STANDARD_HURD_VERSION 
(password);
 /* Port bucket we service requests on.  */
 struct port_bucket *port_bucket;
 
+/* Our port classes.  */
+struct port_class *trivfs_control_class;
+struct port_class *trivfs_protid_class;
+
 /* Trivfs hooks.  */
 int trivfs_fstype = FSTYPE_MISC;
 int trivfs_fsid = 0;
@@ -46,12 +50,6 @@ int trivfs_support_read = 0;
 int trivfs_support_write = 0;
 int trivfs_support_exec = 0;
 int trivfs_allow_open = 0;
-
-struct port_class *trivfs_protid_portclasses[1];
-struct port_class *trivfs_cntl_portclasses[1];
-int trivfs_protid_nportclasses = 1;
-int trivfs_cntl_nportclasses = 1;
-
 
 static int
 password_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
@@ -75,15 +73,23 @@ main (int argc, char *argv[])
   if (bootstrap == MACH_PORT_NULL)
     error (1, 0, "must be started as a translator");
 
-  port_bucket = ports_create_bucket ();
-  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
-  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
-  
+  err = trivfs_add_port_bucket (&port_bucket);
+  if (err)
+    error (1, 0, "error creating port bucket");
+
+  err = trivfs_add_control_port_class (&trivfs_control_class);
+  if (err)
+    error (1, 0, "error creating control port class");
+
+  err = trivfs_add_protid_port_class (&trivfs_protid_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
+
   /* Reply to our parent.  */
   err = trivfs_startup (bootstrap, 0,
-                       trivfs_cntl_portclasses[0], port_bucket,
-                       trivfs_protid_portclasses[0], port_bucket,
-                       &fsys);
+                        trivfs_control_class, port_bucket,
+                        trivfs_protid_class, port_bucket,
+                        &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (3, err, "Contacting parent");
@@ -114,17 +120,17 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
   int count;
   
   /* Stop new requests.  */
-  ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]);
-  ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]);
+  ports_inhibit_class_rpcs (trivfs_control_class);
+  ports_inhibit_class_rpcs (trivfs_protid_class);
 
   /* Are there any extant user ports for the /servers/password file?  */
-  count = ports_count_class (trivfs_protid_portclasses[0]);
+  count = ports_count_class (trivfs_protid_class);
   if (count > 0 && !(flags & FSYS_GOAWAY_FORCE))
     {
       /* We won't go away, so start things going again...  */
-      ports_enable_class (trivfs_protid_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_cntl_portclasses[0]);
-      ports_resume_class_rpcs (trivfs_protid_portclasses[0]);
+      ports_enable_class (trivfs_protid_class);
+      ports_resume_class_rpcs (trivfs_control_class);
+      ports_resume_class_rpcs (trivfs_protid_class);
 
       return EBUSY;
     }
@@ -153,7 +159,7 @@ S_password_check_user (struct trivfs_protid *cred, uid_t 
user, char *pw,
     return EOPNOTSUPP;
 
   if (cred->pi.bucket != port_bucket ||
-      cred->pi.class != trivfs_protid_portclasses[0])
+      cred->pi.class != trivfs_protid_class)
     {
       ports_port_deref (cred);
       return EOPNOTSUPP;
@@ -201,7 +207,7 @@ S_password_check_group (struct trivfs_protid *cred, uid_t 
group, char *pw,
     return EOPNOTSUPP;
 
   if (cred->pi.bucket != port_bucket ||
-      cred->pi.class != trivfs_protid_portclasses[0])
+      cred->pi.class != trivfs_protid_class)
     {
       ports_port_deref (cred);
       return EOPNOTSUPP;
diff --git a/trans/proxy-defpager.c b/trans/proxy-defpager.c
index 5fe8ffd..662f269 100644
--- a/trans/proxy-defpager.c
+++ b/trans/proxy-defpager.c
@@ -30,11 +30,14 @@
 
 static mach_port_t real_defpager, dev_master;
 
+/* Our port class.  */
+struct port_class *trivfs_protid_class;
+
 static error_t
 allowed (mach_port_t port, int mode)
 {
-  struct trivfs_protid *cred = ports_lookup_port
-    (0, port, trivfs_protid_portclasses[0]);
+  struct trivfs_protid *cred
+    = ports_lookup_port (0, port, trivfs_protid_class);
   if (!cred)
     return MIG_BAD_ID;
   error_t result = (cred->po->openmodes & mode) ? 0 : EACCES;
@@ -266,8 +269,12 @@ main (int argc, char **argv)
 
   trivfs_fsid = getpid ();
 
+  err = trivfs_add_protid_port_class (&trivfs_protid_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
+
   /* Reply to our parent.  */
-  err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
+  err = trivfs_startup (bootstrap, 0, 0, 0, trivfs_protid_class, 0, &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (4, err, "Contacting parent");

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]