bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] libnetfs: fsys_goaway


From: Neal H Walfield
Subject: [PATCH] libnetfs: fsys_goaway
Date: Sat, 31 Mar 2001 10:38:19 +0200
User-agent: Mutt/1.3.15i

As inspired by the TODO item:

* Servers
** Implement goaway in all the servers that don't already have it. !!

2001-03-31  Neal H Walfield  <neal@cs.uml.edu>

        * fsys-goaway.c (netfs_S_fsys_goaway):  Actually implement it.
        * shutdown.c (netfs_attempt_shutdown):  Likewise.

        * Makefile (fsys-MIGSFLAGS): Add -DREPLY_PORTS for netfs_S_fsys_goaway.
        * fsys-get-options.c (netfs_S_fsys_getoptions): Add reply ports
        to declaration.
        * fsys-getroot.c (netfs_S_fsys_getroot): Likewise.
        * fsys-goaway.c (netfs_S_fsys_goaway): Likewise.
        * fsys-set-options.c (netfs_S_fsys_set_options): Likewise.
        * fsys-syncfs.c (netfs_S_fsys_syncfs): Likewise.
        * fsysstubs.c (netfs_S_fsys_getfile): Likewise.
        (netfs_S_fsys_getpriv): Likewise.
        (netfs_S_fsys_forward): Likewise.
        (netfs_S_fsys_startup): Likewise.

        * Makefile (MIGSTUBS): Add fsys_replyUser.o.

diff -urN hurd-20010329-snapshot/libnetfs/Makefile 
hurd-20010329/libnetfs/Makefile
--- hurd-20010329-snapshot/libnetfs/Makefile    Tue Jan 30 01:50:25 2001
+++ hurd-20010329/libnetfs/Makefile     Sat Mar 31 09:03:23 2001
@@ -54,11 +54,11 @@
 LCLHDRS = netfs.h callbacks.h misc.h modes.h mutations.h priv.h execserver.h
 installhdrs=netfs.h
 
-MIGSTUBS= ioServer.o fsServer.o fsysServer.o ifsockServer.o
+MIGSTUBS= ioServer.o fsServer.o fsysServer.o fsys_replyUser.o ifsockServer.o
 
 OBJS=$(sort $(SRCS:.c=.o) $(MIGSTUBS))
 
-fsys-MIGSFLAGS = -imacros $(srcdir)/mutations.h
+fsys-MIGSFLAGS = -imacros $(srcdir)/mutations.h -DREPLY_PORTS
 fs-MIGSFLAGS = -imacros $(srcdir)/mutations.h
 io-MIGSFLAGS = -imacros $(srcdir)/mutations.h
 ifsock-MIGSFLAGS = -imacros $(srcdir)/mutations.h
diff -urN hurd-20010329-snapshot/libnetfs/fsys-get-options.c 
hurd-20010329/libnetfs/fsys-get-options.c
--- hurd-20010329-snapshot/libnetfs/fsys-get-options.c  Thu Aug 20 08:01:25 1998
+++ hurd-20010329/libnetfs/fsys-get-options.c   Sat Mar 31 08:58:01 2001
@@ -1,6 +1,6 @@
 /* Unparse run-time options
 
-   Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1998, 2001 Free Software Foundation, Inc.
 
    This file is part of the GNU Hurd.
 
@@ -32,6 +32,8 @@
 /* Implement fsys_get_options as described in <hurd/fsys.defs>. */
 error_t
 netfs_S_fsys_get_options (fsys_t fsys,
+                         mach_port_t reply,
+                         mach_msg_type_name_t reply_type,
                          char **data, mach_msg_type_number_t *data_len)
 {
   error_t err;
diff -urN hurd-20010329-snapshot/libnetfs/fsys-getroot.c 
hurd-20010329/libnetfs/fsys-getroot.c
--- hurd-20010329-snapshot/libnetfs/fsys-getroot.c      Fri Jun 20 07:47:39 1997
+++ hurd-20010329/libnetfs/fsys-getroot.c       Sat Mar 31 08:55:50 2001
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -26,6 +26,8 @@
 
 error_t
 netfs_S_fsys_getroot (mach_port_t cntl,
+                     mach_port_t reply,
+                     mach_msg_type_name_t reply_type,
                      mach_port_t dotdot,
                      uid_t *uids, mach_msg_type_number_t nuids,
                      uid_t *gids, mach_msg_type_number_t ngids,
diff -urN hurd-20010329-snapshot/libnetfs/fsys-goaway.c 
hurd-20010329/libnetfs/fsys-goaway.c
--- hurd-20010329-snapshot/libnetfs/fsys-goaway.c       Thu Jan  1 01:00:00 1970
+++ hurd-20010329/libnetfs/fsys-goaway.c        Sat Mar 31 08:56:16 2001
@@ -0,0 +1,54 @@
+/* Copyright (C) 1993,94,95,2001 Free Software Foundation
+
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   The GNU Hurd 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
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
+
+/* Written by Michael I. Bushnell.  */
+
+#include "priv.h"
+#include "netfs.h"
+#include "fsys_S.h"
+#include "fsys_reply_U.h"
+
+#include <stdlib.h>
+#include <errno.h>
+#include <hurd/ports.h>
+
+error_t
+netfs_S_fsys_goaway (fsys_t control,
+                    mach_port_t reply,
+                    mach_msg_type_name_t reply_type,
+                    int flags)
+{
+  error_t err;
+  struct port_info *pt;
+  
+  pt = ports_lookup_port (netfs_port_bucket, control,
+                         netfs_control_class);
+  if (! pt)
+    return EOPNOTSUPP;
+
+  err = netfs_shutdown (flags);
+  if (! err)
+    {
+      fsys_goaway_reply (reply, reply_type, 0);
+      exit (0);
+    }
+
+  ports_port_deref (pt);
+
+  return err;
+}
diff -urN hurd-20010329-snapshot/libnetfs/fsys-set-options.c 
hurd-20010329/libnetfs/fsys-set-options.c
--- hurd-20010329-snapshot/libnetfs/fsys-set-options.c  Wed Jun 26 23:02:18 1996
+++ hurd-20010329/libnetfs/fsys-set-options.c   Sat Mar 31 08:56:28 2001
@@ -1,6 +1,6 @@
 /* Parse run-time options
 
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
 
    This file is part of the GNU Hurd.
 
@@ -32,6 +32,8 @@
 /* Implement fsys_set_options as described in <hurd/fsys.defs>. */
 error_t
 netfs_S_fsys_set_options (fsys_t fsys,
+                         mach_port_t reply,
+                         mach_msg_type_name_t reply_type,
                          char *data, mach_msg_type_number_t data_len,
                          int do_children)
 {
diff -urN hurd-20010329-snapshot/libnetfs/fsys-syncfs.c 
hurd-20010329/libnetfs/fsys-syncfs.c
--- hurd-20010329-snapshot/libnetfs/fsys-syncfs.c       Thu Nov 21 00:19:37 1996
+++ hurd-20010329/libnetfs/fsys-syncfs.c        Sat Mar 31 08:56:46 2001
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 2001 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -23,6 +23,8 @@
 
 error_t
 netfs_S_fsys_syncfs (mach_port_t cntl,
+                    mach_port_t reply,
+                    mach_msg_type_name_t reply_type,
                     int wait,
                     int children)
 {
diff -urN hurd-20010329-snapshot/libnetfs/fsysstubs.c 
hurd-20010329/libnetfs/fsysstubs.c
--- hurd-20010329-snapshot/libnetfs/fsysstubs.c Tue Mar  5 01:34:01 1996
+++ hurd-20010329/libnetfs/fsysstubs.c  Sat Mar 31 09:09:29 2001
@@ -1,6 +1,6 @@
 /* Unimplemented rpcs from <hurd/fsys.defs>
  
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -24,6 +24,8 @@
 
 error_t
 netfs_S_fsys_getfile (fsys_t cntl,
+                     mach_port_t reply,
+                     mach_msg_type_name_t reply_type,
                      uid_t *uids, mach_msg_type_number_t nuids,
                      gid_t *gids, mach_msg_type_number_t ngids,
                      char *handle, mach_msg_type_number_t handlelen,
@@ -34,6 +36,8 @@
 
 error_t
 netfs_S_fsys_getpriv (fsys_t cntl,
+                     mach_port_t reply,
+                     mach_msg_type_name_t reply_type,
                      mach_port_t *host, mach_msg_type_name_t *hosttp,
                      mach_port_t *dev, mach_msg_type_name_t *devtp,
                      mach_port_t *fs, mach_msg_type_name_t *fstp)
@@ -43,7 +47,8 @@
 
 error_t
 netfs_S_fsys_init (fsys_t cntl,
-                  mach_port_t reply, mach_msg_type_name_t replytp,
+                  mach_port_t reply,
+                  mach_msg_type_name_t reply_type,
                   mach_port_t proc, auth_t auth)
 {
   return EOPNOTSUPP;
@@ -51,6 +56,8 @@
 
 error_t
 netfs_S_fsys_forward (fsys_t cntl,
+                     mach_port_t reply,
+                     mach_msg_type_name_t reply_type,
                      mach_port_t request,
                      char *argv, mach_msg_type_number_t argvlen)
 {
@@ -59,17 +66,12 @@
 
 error_t
 netfs_S_fsys_startup (mach_port_t bootstrap,
+                     mach_port_t reply,
+                     mach_msg_type_name_t reply_type,
                      int flags,
                      mach_port_t contrl,
                      mach_port_t *realnod,
                      mach_msg_type_name_t *realnodetype)
-{
-  return EOPNOTSUPP;
-}
-
-error_t
-netfs_S_fsys_goaway (mach_port_t cntl,
-                    int flags)
 {
   return EOPNOTSUPP;
 }
diff -urN hurd-20010329-snapshot/libnetfs/shutdown.c 
hurd-20010329/libnetfs/shutdown.c
--- hurd-20010329-snapshot/libnetfs/shutdown.c  Tue Jan 30 20:57:35 1996
+++ hurd-20010329/libnetfs/shutdown.c   Sat Mar 31 09:12:24 2001
@@ -1,28 +1,106 @@
-/* 
-   Copyright (C) 1996 Free Software Foundation, Inc.
-   Written by Michael I. Bushnell, p/BSG.
-
-   This file is part of the GNU Hurd.
-
-   The GNU Hurd is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   The GNU Hurd 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
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
+/*
+   Copyright (C) 1993,94,95,96,98,99,2001 Free Software Foundation, Inc.
 
-#include "netfs.h"
+This file is part of the GNU Hurd.
 
+The GNU Hurd is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+The GNU Hurd 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU Hurd; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/* Written by Michael I. Bushnell.  */
+
+#include "priv.h"
+#include <errno.h>
+#include <sys/stat.h>
+#include <hurd/fsys.h>
+#include <hurd/fshelp.h>
+#include <cthreads.h>
+
+/* Shutdown the filesystem; flags are as for fsys_goaway. */
 error_t
 netfs_shutdown (int flags)
 {
-  return EBUSY;
-}
+  error_t
+  helper (struct node *node)
+    {
+      error_t err;
+      mach_port_t control;
+
+      err = fshelp_fetch_control (&node->transbox, &control);
+      if (!err && (control != MACH_PORT_NULL))
+        {
+          mutex_unlock (&node->lock);
+          err = fsys_goaway (control, flags);
+          mach_port_deallocate (mach_task_self (), control);
+          mutex_lock (&node->lock);
+        }
+      else
+        err = 0;
+
+      if ((err == MIG_SERVER_DIED) || (err == MACH_SEND_INVALID_DEST))
+        err = 0;
+
+      return err;
+    }
+
+  int nports;
+  int err;
+
+  if ((flags & FSYS_GOAWAY_UNLINK)
+      && S_ISDIR (netfs_root_node->nn_stat.st_mode))
+    return EBUSY;
+
+#ifdef NOTYET
+  if (flags & FSYS_GOAWAY_RECURSE)
+    {
+      err = netfs_node_iterate (helper);
+      if (err)
+       return err;
+    }
+#endif
+
+#ifdef NOTYET
+  rwlock_writer_lock (&netfs_fsys_lock);
+#endif
+
+  /* Permit all current RPC's to finish, and then suspend any new ones.  */
+  err = ports_inhibit_class_rpcs (netfs_protid_class);
+  if (err)
+    {
+#ifdef  NOTYET
+      rwlock_writer_unlock (&netfs_fsys_lock);
+#endif
+      return err;
+    }
+
+  nports = ports_count_class (netfs_protid_class);
+  if (((flags & FSYS_GOAWAY_FORCE) == 0) && nports)
+    /* There are outstanding user ports; resume operations. */
+    {
+      ports_enable_class (netfs_protid_class);
+      ports_resume_class_rpcs (netfs_protid_class);
+#ifdef NOTYET
+      rwlock_writer_unlock (&netfs_fsys_lock);
+#endif
+      return EBUSY;
+    }
+
+  if (!(flags & FSYS_GOAWAY_NOSYNC))
+    {
+      err = netfs_attempt_syncfs (0, flags);
+      if (err)
+        return err;
+    }
 
+  return 0;
+}

Attachment: pgpLRYiegxK0N.pgp
Description: PGP signature


reply via email to

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