bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] libnetfs documentation / audit


From: Neal H Walfield
Subject: [PATCH] libnetfs documentation / audit
Date: Fri, 29 Dec 2000 13:31:15 -0500
User-agent: Mutt/1.2.5i

I have audited most of libnetfs and added a lot of documentation to
hurd/netfs.h.  Most importantly in the latter case is that I have
explicitly outlined the locking protocol.

-Neal

-- 
Neal H Walfield
University of Massachusetts at Lowell
neal@walfield.org or neal@cs.uml.edu

Index: libnetfs/ChangeLog
===================================================================
RCS file: /cvs/hurd/libnetfs/ChangeLog,v
retrieving revision 1.46
diff -u -r1.46 ChangeLog
--- libnetfs/ChangeLog  2000/03/17 19:41:02     1.46
+++ libnetfs/ChangeLog  2000/12/29 18:28:10
@@ -1,3 +1,23 @@
+2000-12-29  Neal H Walfield <neal@cs.uml.edu>
+
+        * dir-lookup.c (netfs_S_dir_lookup):  Do not bother zeroing np, it
+       happens later anyway.  Replace bcopy with memcpy.
+       * file-get-translator.c (netfs_S_file_get_translator): Replace
+       bcopy with memcpy.
+       * file-set-translator.c (netfs_S_file_set_translator): Turn
+       complex if into a simple switch.
+       * io-revoke.c (netfs_S_io_revoke): Fix indentation.  Fix return
+       type.
+       * io-seek.c (netfs_S_io_seek): Only get the lock if we need it.
+       * io-stat.c (netfs_S_io_stat): Replace bcopy with memcpy.
+       * io-write.c (netfs_S_io_write): Wait until the lock is needed.
+       * make-node.c (netfs_make_node): Verify what malloc returns.
+       * netfs.h: Complete documentation revision.  The locking protocol
+       is now very explicit.
+       * nput.c (netfs_nput): Added comments.
+       * nrele.c (netfs_nrele): Likewise.
+       * set-get-trans.c: Likewise.
+
 2000-03-17  Roland McGrath  <roland@baalperazim.frob.com>
 
        * file-exec.c (netfs_S_file_exec): Fix typo and braino in last change.
Index: libnetfs/dir-lookup.c
===================================================================
RCS file: /cvs/hurd/libnetfs/dir-lookup.c,v
retrieving revision 1.19
diff -u -r1.19 dir-lookup.c
--- libnetfs/dir-lookup.c       2000/03/17 10:30:55     1.19
+++ libnetfs/dir-lookup.c       2000/12/29 18:28:12
@@ -75,7 +75,6 @@
 
   dnp = diruser->po->np;
   mutex_lock (&dnp->lock);
-  np = 0;
 
   netfs_nref (dnp);            /* acquire a reference for later netfs_nput */
 
@@ -300,7 +299,7 @@
          if (nextname)
            {
              linkbuf[linklen] = '/';
-             bcopy (nextname, linkbuf + linklen + 1,
+             memcpy (linkbuf + linklen + 1, nextname,
                     nextnamelen - 1);
            }
          linkbuf[nextnamelen + linklen] = '\0';
Index: libnetfs/file-get-translator.c
===================================================================
RCS file: /cvs/hurd/libnetfs/file-get-translator.c,v
retrieving revision 1.7
diff -u -r1.7 file-get-translator.c
--- libnetfs/file-get-translator.c      1999/07/11 19:56:48     1.7
+++ libnetfs/file-get-translator.c      2000/12/29 18:28:13
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1999, 2000 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -52,7 +52,7 @@
 
       if (len  > *translen)
        *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
-      bcopy (_HURD_SYMLINK, *trans, sizeof _HURD_SYMLINK);
+      memcpy (*trans, _HURD_SYMLINK, sizeof _HURD_SYMLINK);
 
       err = netfs_attempt_readlink (user->user, np,
                                    *trans + sizeof _HURD_SYMLINK);
@@ -77,7 +77,7 @@
 
       if (buflen > *translen)
        *trans = mmap (0, buflen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
-      bcopy (buf, *trans, buflen);
+      memcpy (*trans, buf, buflen);
       free (buf);
       *translen = buflen;
       err = 0;
@@ -89,7 +89,7 @@
       len = sizeof _HURD_FIFO;
       if (len > *translen)
        *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
-      bcopy (_HURD_FIFO, *trans, sizeof _HURD_FIFO);
+      memcpy (*trans, _HURD_FIFO, sizeof _HURD_FIFO);
       *translen = len;
       err = 0;
     }
@@ -100,7 +100,7 @@
       len = sizeof _HURD_IFSOCK;
       if (len > *translen)
         *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
-      bcopy (_HURD_IFSOCK, *trans, sizeof _HURD_IFSOCK);
+      memcpy (*trans, _HURD_IFSOCK, sizeof _HURD_IFSOCK);
       *translen = len;
       err = 0;
     }
Index: libnetfs/file-set-translator.c
===================================================================
RCS file: /cvs/hurd/libnetfs/file-set-translator.c,v
retrieving revision 1.8
diff -u -r1.8 file-set-translator.c
--- libnetfs/file-set-translator.c      1999/01/24 02:32:47     1.8
+++ libnetfs/file-set-translator.c      2000/12/29 18:28:13
@@ -65,9 +65,15 @@
        {
          mutex_unlock (&np->lock);
          err = fsys_goaway (control, killtrans_flags);
-         if (err && err != MIG_SERVER_DIED && err != MACH_SEND_INVALID_DEST)
-           return err;
-         err = 0;
+         switch (err)
+           {
+           case 0:
+           case MIG_SERVER_DIED:
+           case MACH_SEND_INVALID_DEST:
+             err = 0;
+           default:
+             return err;
+           }
          mutex_lock (&np->lock);
        }
     }
Index: libnetfs/io-revoke.c
===================================================================
RCS file: /cvs/hurd/libnetfs/io-revoke.c,v
retrieving revision 1.6
diff -u -r1.6 io-revoke.c
--- libnetfs/io-revoke.c        1999/02/28 20:50:09     1.6
+++ libnetfs/io-revoke.c        2000/12/29 18:28:14
@@ -27,15 +27,15 @@
   struct node *np;
 
   error_t
-    iterator_function (void *port)
-    {
-      struct protid *user = port;
+  iterator_function (void *port)
+  {
+    struct protid *user = port;
 
-      if ((user != cred)
-         && (user->po->np == np))
-       ports_destroy_right (user);
-      return 0;
-    }
+    if ((user != cred)
+        && (user->po->np == np))
+      ports_destroy_right (user);
+    return 0;
+  }
 
   if (!cred)
     return EOPNOTSUPP;
Index: libnetfs/io-seek.c
===================================================================
RCS file: /cvs/hurd/libnetfs/io-seek.c,v
retrieving revision 1.6
diff -u -r1.6 io-seek.c
--- libnetfs/io-seek.c  1996/11/18 23:50:59     1.6
+++ libnetfs/io-seek.c  2000/12/29 18:28:14
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -33,7 +33,6 @@
   if (!user)
     return EOPNOTSUPP;
 
-  mutex_lock (&user->po->np->lock);
   switch (whence)
     {
     case SEEK_SET:
@@ -47,17 +46,27 @@
       break;
       
     case SEEK_END:
-      err = netfs_validate_stat (user->po->np, user->user);
-      if (!err)
-       user->po->filepointer = user->po->np->nn_stat.st_size + offset;
-      break;
+      {
+        struct node *np;
+
+        np = user->po->np;
+        mutex_lock (&np->lock);
+
+        err = netfs_validate_stat (np, user->user);
+        if (!err)
+         user->po->filepointer = np->nn_stat.st_size + offset;
+
+        mutex_unlock (&np->lock);
+
+        break;
+      }
       
     default:
       err = EINVAL;
       break;
     }
+
   *newoffset = user->po->filepointer;
-  mutex_unlock (&user->po->np->lock);
   return err;
 }
 
Index: libnetfs/io-stat.c
===================================================================
RCS file: /cvs/hurd/libnetfs/io-stat.c,v
retrieving revision 1.4
diff -u -r1.4 io-stat.c
--- libnetfs/io-stat.c  1997/06/20 05:46:44     1.4
+++ libnetfs/io-stat.c  2000/12/29 18:28:14
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -37,7 +37,7 @@
   err = netfs_validate_stat (node, user->user);
   if (! err)
     {
-      bcopy (&node->nn_stat, statbuf, sizeof (struct stat));
+      memcpy (statbuf, &node->nn_stat, sizeof (struct stat));
 
       /* Set S_IATRANS and S_IROOT bits as appropriate.  */
       statbuf->st_mode &= ~(S_IATRANS | S_IROOT);
Index: libnetfs/io-write.c
===================================================================
RCS file: /cvs/hurd/libnetfs/io-write.c,v
retrieving revision 1.8
diff -u -r1.8 io-write.c
--- libnetfs/io-write.c 1996/11/18 23:51:06     1.8
+++ libnetfs/io-write.c 2000/12/29 18:28:15
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -36,16 +36,13 @@
   if (!user)
     return EOPNOTSUPP;
   
-  np = user->po->np;
-
-  mutex_lock (&np->lock);
   if ((user->po->openstat & O_WRITE) == 0)
-    {
-      mutex_unlock (&np->lock);
-      return EBADF;
-    }
+    return EBADF;
 
   *amount = datalen;
+
+  np = user->po->np;
+  mutex_lock (&np->lock);
 
   if (off == -1)
     {
Index: libnetfs/make-node.c
===================================================================
RCS file: /cvs/hurd/libnetfs/make-node.c,v
retrieving revision 1.4
diff -u -r1.4 make-node.c
--- libnetfs/make-node.c        1996/07/03 15:55:32     1.4
+++ libnetfs/make-node.c        2000/12/29 18:28:15
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd.
@@ -20,11 +20,17 @@
 
 #include "netfs.h"
 #include <hurd/fshelp.h>
+#include <errno.h>
 
 struct node *
 netfs_make_node (struct netnode *nn)
 {
   struct node *np = malloc (sizeof (struct node));
+  if (! np)
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
   
   np->nn = nn;
 
Index: libnetfs/netfs.h
===================================================================
RCS file: /cvs/hurd/libnetfs/netfs.h,v
retrieving revision 1.23
diff -u -r1.23 netfs.h
--- libnetfs/netfs.h    1999/07/01 21:30:37     1.23
+++ libnetfs/netfs.h    2000/12/29 18:28:18
@@ -1,6 +1,6 @@
 /* 
 
-   Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation
+   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -69,17 +69,22 @@
 {
   struct node *next, **prevp;
   
-  /* Protocol specific stuff. */
+  /* Protocol specific stuff; defined by user */
   struct netnode *nn;
 
+  /* The stat information for this particular node */
   struct stat nn_stat;
   
+  /* Whenever the node is touch (for reading or writing), this
+     _must_ be held */
   struct mutex lock;
   
+  /* The number of references to this node.  This may only be adjusted
+     via the netfs_nrele, netfs_nput and netfs_nref functions */
   int references;
   
   mach_port_t sockaddr;
-  
+
   int owner;
   
   struct transbox transbox;
@@ -92,45 +97,58 @@
 };
 
 /* The user must define this function.  Make sure that NP->nn_stat is
-   filled with current information.  CRED identifies the user
-   responsible for the operation.  */
-error_t netfs_validate_stat (struct node *NP, struct iouser *cred);
+   filled with the most current information.  CRED identifies the user
+   responsible for the operation.
+ 
+   NP must be locked on entry and exit. */
+error_t netfs_validate_stat (struct node *np, struct iouser *cred);
 
 /* The user must define this function.  This should attempt a chmod
    call for the user specified by CRED on node NODE, to change the
-   owner to UID and the group to GID. */
+   owner to UID and the group to GID.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_chown (struct iouser *cred, struct node *np,
                             uid_t uid, uid_t gid);
 
 /* The user must define this function.  This should attempt a chauthor
-   call for the user specified by CRED on node NODE, to change the
-   author to AUTHOR. */
+   call for the user specified by CRED on node NODE, thereby changing
+   the author to AUTHOR.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_chauthor (struct iouser *cred, struct node *np,
                                uid_t author);
 
 /* The user must define this function.  This should attempt a chmod
-   call for the user specified by CRED on node NODE, to change the
-   mode to MODE.  Unlike the normal Unix and Hurd meaning of chmod,
+   call for the user specified by CRED on node NODE, thereby changing
+   the mode to MODE.  Unlike the normal Unix and Hurd meaning of chmod,
    this function is also used to attempt to change files into other
    types.  If such a transition is attempted which is impossible, then
    return EOPNOTSUPP.
-  */
+
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_chmod (struct iouser *cred, struct node *np,
                             mode_t mode);
 
 /* The user must define this function.  Attempt to turn NODE (user CRED)
-   into a symlink with target NAME. */
+   into a symlink with target NAME.
+
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_mksymlink (struct iouser *cred, struct node *np,
                                 char *name);
 
 /* The user must define this function.  Attempt to turn NODE (user
-   CRED) into a device.  TYPE is either S_IFBLK or S_IFCHR. */
+   CRED) into a device.  TYPE is either S_IFBLK or S_IFCHR.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_mkdev (struct iouser *cred, struct node *np,
                             mode_t type, dev_t indexes);
 
 /* The user may define this function.  Attempt to set the passive
    translator record for FILE to ARGZ (of length ARGZLEN) for user
-   CRED. */
+   CRED.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_set_translator (struct iouser *cred, struct node *np,
                              char *argz, size_t argzlen);
 
@@ -138,139 +156,187 @@
    netfs_set_translator).  For locked node NODE with S_IPTRANS set in its
    mode, look up the name of its translator.  Store the name into newly
    malloced storage, and return it in *ARGZ; set *ARGZ_LEN to the total
-   length.  */
+   length.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_get_translator (struct node *node, char **argz, size_t 
*argz_len);
 
 /* The user must define this function.  This should attempt a chflags
    call for the user specified by CRED on node NODE, to change the
-   flags to FLAGS. */
+   flags to FLAGS.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_chflags (struct iouser *cred, struct node *np,
                               int flags);
 
 /* The user must define this function.  This should attempt a utimes
    call for the user specified by CRED on node NODE, to change the
    atime to ATIME and the mtime to MTIME.  If ATIME or MTIME is null,
-   then set to the current time.  */
+   then set to the current time.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_utimes (struct iouser *cred, struct node *np,
                              struct timespec *atime, struct timespec *mtime);
 
 /* The user must define this function.  This should attempt to set the
-   size of the file NODE (for user CRED) to SIZE bytes long. */
+   size of the file NODE (for user CRED) to SIZE bytes long.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_set_size (struct iouser *cred, struct node *np,
                                off_t size);
 
 /* The user must define this function.  This should attempt to fetch
    filesystem status information for the remote filesystem, for the
-   user CRED. */
+   user CRED.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_statfs (struct iouser *cred, struct node *np,
                              struct statfs *st);
 
 /* The user must define this function.  This should sync the file NP
    completely to disk, for the user CRED.  If WAIT is set, return
-   only after sync is completely finished.  */
+   only after the sync is completely finished.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_sync (struct iouser *cred, struct node *np,
                            int wait);
 
 /* The user must define this function.  This should sync the entire
-   remote filesystem.  If WAIT is set, return only after
-   sync is completely finished.  */
+   remote filesystem.  If WAIT is set, return only after the
+   sync is completely finished. */
 error_t netfs_attempt_syncfs (struct iouser *cred, int wait);
 
 /* The user must define this function.  Lookup NAME in DIR for USER;
    set *NP to the found name upon return.  If the name was not found,
-   then return ENOENT.  On any error, clear *NP.  (*NP, if found, should
-   be locked, this call should unlock DIR no matter what.) */
+   then return ENOENT.  On any error, clear *NP.
+   
+   DIR must be locked on entry and unlocked on exit.  *NP, if found,
+   must be locked on exit. */
 error_t netfs_attempt_lookup (struct iouser *user, struct node *dir, 
                              char *name, struct node **np);
 
-/* The user must define this function.  Delete NAME in DIR for USER. */
+/* The user must define this function.  Delete NAME in DIR for USER.
+ 
+   DIR must be locked on entry and exit. */
 error_t netfs_attempt_unlink (struct iouser *user, struct node *dir,
                              char *name);
 
-/* Note that in this one call, neither of the specific nodes are locked. */
+/* The user must define this function.  Attempt to rename the directory
+   FROMDIR to TODIR.
+  
+   Neither FROMDIR nor TODIR are locked on entry or exit. */
 error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir,
                              char *fromname, struct node *todir, 
                              char *toname, int excl);
 
 /* The user must define this function.  Attempt to create a new
-   directory named NAME in DIR for USER with mode MODE.  */
+   directory named NAME in DIR for USER with mode MODE.
+ 
+   DIR must be locked on entry and exit. */
 error_t netfs_attempt_mkdir (struct iouser *user, struct node *dir,
                             char *name, mode_t mode);
 
 /* The user must define this function.  Attempt to remove directory
-   named NAME in DIR for USER. */
+   named NAME in DIR for USER.
+ 
+   DIR must be locked on entry and exit. */
 error_t netfs_attempt_rmdir (struct iouser *user, 
                             struct node *dir, char *name);
 
 
 /* The user must define this function.  Create a link in DIR with name
-   NAME to FILE for USER.  Note that neither DIR nor FILE are
-   locked.  If EXCL is set, do not delete the target, but return EEXIST
-   if NAME is already found in DIR.   */
+   NAME to FILE for USER.  If EXCL is set, do not delete the target.
+   Return EEXIST if NAME is already found in DIR.
+   
+   Neither DIR nor FILE are locked on entry or exit. */
 error_t netfs_attempt_link (struct iouser *user, struct node *dir,
                            struct node *file, char *name, int excl);
 
 /* The user must define this function.  Attempt to create an anonymous
    file related to DIR for USER with MODE.  Set *NP to the returned
-   file upon success.  No matter what, unlock DIR. */
+   file upon success.
+   
+   DIR must be locked on entry and unlocked on exit. */
 error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir,
                              mode_t mode, struct node **np);
 
 /* The user must define this function.  Attempt to create a file named
    NAME in DIR for USER with MODE.  Set *NP to the new node upon
-   return.  On any error, clear *NP.  *NP should be locked on success;
-   no matter what, unlock DIR before returning.  */
+   return.  On any error, clear *NP.
+ 
+   DIR must be locked on entry and unlocked on exit.  If successful,
+   *NP must be locked exit. */
 error_t netfs_attempt_create_file (struct iouser *user, struct node *dir,
                                   char *name, mode_t mode, struct node **np);
 
 /* The user must define this function.  Read the contents of NP (a symlink),
-   for USER, into BUF. */
+   for USER, into BUF.
+
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_readlink (struct iouser *user, struct node *np,
                                char *buf);
 
 /* The user must define this function.  Node NP is being opened by USER,
    with FLAGS.  NEWNODE is nonzero if we just created this node.  Return
    an error if we should not permit the open to complete because of a
-   permission restriction. */
+   permission restriction.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_check_open_permissions (struct iouser *user, struct node *np,
                                      int flags, int newnode);
 
 /* The user must define this function.  Read from the file NP for user
    CRED starting at OFFSET and continuing for up to *LEN bytes.  Put
    the data at DATA.  Set *LEN to the amount successfully read upon
-   return.  */
+   return.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_read (struct iouser *cred, struct node *np,
                            off_t offset, size_t *len, void *data);
 
 /* The user must define this function.  Write to the file NP for user
    CRED starting at OFSET and continuing for up to *LEN bytes from
-   DATA.  Set *LEN to the amount seccessfully written upon return. */
+   DATA.  Set *LEN to the amount seccessfully written upon return.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_attempt_write (struct iouser *cred, struct node *np,
                             off_t offset, size_t *len, void *data);
 
 /* The user must define this function.  Return the valid access
    types (bitwise OR of O_READ, O_WRITE, and O_EXEC) in *TYPES for
-   file NP and user CRED.   */
+   file NP and user CRED.
+ 
+   NP must be locked on entry and exit. */
 error_t netfs_report_access (struct iouser *cred, struct node *np,
                             int *types);
 
-/* The user must define this function.  Create a new user
-   from the specified UID and GID arrays. */
+/* The user must define this function.  Create a new user from the
+   specified UID and GID arrays. */
 struct iouser *netfs_make_user (uid_t *uids, int nuids,
                                       uid_t *gids, int ngids);
 
-/* The user must define this function.  Node NP is all done; free
-   all its associated storage. */
+/* The user must define this function.  Node NP has no more references;
+   free all its associated storage. */
 void netfs_node_norefs (struct node *np);
 
-error_t netfs_get_dirents (struct iouser *, struct node *, int, int, char **,
-                          mach_msg_type_number_t *, vm_size_t, int *);
+/* The user must define this function.  Fill the array *DATA of
+   size BUFSIZE with up to NENTRIES dirents from DIR starting with
+   entry ENTRY for user CRED.  The number of entries in the array is
+   stored in *AMT and the number of bytes in *DATACNT.  If the
+   supplied buffer is not large enough to hold the data, it should
+   be grown.
+
+   DIR must be lock on entry and exit. */
+error_t netfs_get_dirents (struct iouser *cred, struct node *dir,
+                           int entry, int nentries, char **data,
+                          mach_msg_type_number_t *datacnt,
+                          vm_size_t bufsize, int *amt);
 
 /* Option parsing */
 
 /* Parse and execute the runtime options in ARGZ & ARGZ_LEN.  EINVAL is
    returned if some option is unrecognized.  The default definition of this
-   routine will parse them using NETFS_RUNTIME_ARGP, which see.  */
+   routine will parse them using NETFS_RUNTIME_ARGP. */
 error_t netfs_set_options (char *argz, size_t argz_len);
 
 /* Append to the malloced string *ARGZ of length *ARGZ_LEN a NUL-separated
@@ -281,7 +347,7 @@
 /* If this is defined or set to a pointer to an argp structure, it will be
    used by the default netfs_set_options to handle runtime option parsing.
    The default definition is initialized to a pointer to
-   NETFS_STD_RUNTIME_ARGP.  Setting this variable is the usual way to add
+   NETFS_STD_RUNTIME_ARGP.  Set this variable is the usual way to add
    option parsing to a program using libnetfs.  */
 extern struct argp *netfs_runtime_argp;
 
@@ -300,18 +366,38 @@
    must already have a sane value).  */
 error_t netfs_append_std_options (char **argz, size_t *argz_len);
 
+/* Definitions provided by user */
+
+/* Maximum number of symlinks to follow before returning ELOOP. */
+extern int netfs_maxsymlinks;
+
 /* Definitions provided by netfs. */
-struct node *netfs_make_node (struct netnode *);
 
-mach_port_t netfs_startup (mach_port_t, int);
+/* Given a netnode created by the user program, wraps it in a node
+   structure.  The new node is unlock and has a single reference.
+   If an error occurs, NULL is returned and errno is set. */
+struct node *netfs_make_node (struct netnode *);
 
+/* When ever node->np is to be touched, this lock must be held.
+   Cf. netfs_nrele, netfs_nput, netfs_ref and netfs_drop_node. */
 extern spin_lock_t netfs_node_refcnt_lock;
-
-extern int netfs_maxsymlinks;
 
+/* Normally called in main.  This function sets up some of the netfs
+   server's internal state. */
 void netfs_init (void);
+
+/* Starts the netfs server.  Called after netfs_init. BOOTSTRAP is
+   the bootstrap port.  FLAGS indicate how to open the underlying node
+   (Cf. hurd/fsys.defs). */
+mach_port_t netfs_startup (mach_port_t bootstrap, int flags);
+
+/* Normally called as the last function in main.  The netfs server
+   is now begins answering requests. This function never returns. */
 void netfs_server_loop (void);
-struct protid *netfs_make_protid (struct peropen *, struct iouser *);
+
+/* Creates a new credential from USER which can be NULL on the peropen
+   PO. Returns NULL and sets errno on error. */
+struct protid *netfs_make_protid (struct peropen *po, struct iouser *user);
 
 /* Create and return a new peropen structure on node NP with open
    flags FLAGS.  The initial values for the root_parent, shadow_root, and
@@ -319,12 +405,36 @@
    otherwise zerod.  */
 struct peropen *netfs_make_peropen (struct node *, int,
                                    struct peropen *context);
+
+/* Add a reference to node NP which  must be lock for the duration of
+   this call. */
+void netfs_nref (struct node *np);
+
+/* Releases a node.  Drops a reference to node NP which on entry
+   is unlocked.  This node cannot be used again without first obtaining
+   a reference to it. */
+void netfs_nrele (struct node *np);
+
+/* Puts a node back.  Drops a reference to the node NP which is locked
+   on entry.  This node cannot be used again without first obtaining
+   a reference to it. */
+void netfs_nput (struct node *np);
 
-void netfs_drop_node (struct node *);
+/* Called internally when no more references to node NP exist. */
+void netfs_drop_node (struct node *np);
+
+/* Called internally when no more references to a protid exit. */
 void netfs_release_protid (void *);
+
+/* Called internally when no more references to a protid exit. */
 void netfs_release_peropen (struct peropen *);
+
+/* The netfs message demuxer. */
 int netfs_demuxer (mach_msg_header_t *, mach_msg_header_t *);
-error_t netfs_shutdown (int);
+
+/* Called to ask the filesystem to shutdown.  If it returns, an error
+   occured.  FLAGS are passed to fsys_goaway. */
+error_t netfs_shutdown (int flags);
 
 extern struct port_class *netfs_protid_class;
 extern struct port_class *netfs_control_class;
@@ -332,10 +442,6 @@
 extern struct node *netfs_root_node;
 extern mach_port_t netfs_fsys_identity;
 extern auth_t netfs_auth_server_port;
-
-void netfs_nref (struct node *np);
-void netfs_nrele (struct node *np);
-void netfs_nput (struct node *np);
 
 
 /* Mig gook. */
Index: libnetfs/nput.c
===================================================================
RCS file: /cvs/hurd/libnetfs/nput.c,v
retrieving revision 1.1
diff -u -r1.1 nput.c
--- libnetfs/nput.c     1999/07/01 21:30:37     1.1
+++ libnetfs/nput.c     2000/12/29 18:28:18
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
    Written by Thomas Bushnell, BSG.
 
    This file is part of the GNU Hurd.
@@ -28,6 +28,7 @@
   np->references--;
   if (np->references == 0)
     netfs_drop_node (np);
+    /* netfs_drop_node drops netfs_node_refcnt_lock */
   else
     {
       spin_unlock (&netfs_node_refcnt_lock);
Index: libnetfs/nref.c
===================================================================
RCS file: /cvs/hurd/libnetfs/nref.c,v
retrieving revision 1.1
diff -u -r1.1 nref.c
--- libnetfs/nref.c     1999/07/01 21:30:38     1.1
+++ libnetfs/nref.c     2000/12/29 18:28:18
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
    Written by Thomas Bushnell, BSG.
 
    This file is part of the GNU Hurd.
Index: libnetfs/nrele.c
===================================================================
RCS file: /cvs/hurd/libnetfs/nrele.c,v
retrieving revision 1.1
diff -u -r1.1 nrele.c
--- libnetfs/nrele.c    1999/07/01 21:30:38     1.1
+++ libnetfs/nrele.c    2000/12/29 18:28:18
@@ -30,6 +30,7 @@
     {
       mutex_lock (&np->lock);
       netfs_drop_node (np);
+      /* netfs_drop_node drops netfs_node_refcnt_lock */
     }
   else
     spin_unlock (&netfs_node_refcnt_lock);
Index: libnetfs/set-get-trans.c
===================================================================
RCS file: /cvs/hurd/libnetfs/set-get-trans.c,v
retrieving revision 1.1
diff -u -r1.1 set-get-trans.c
--- libnetfs/set-get-trans.c    1997/06/20 05:45:25     1.1
+++ libnetfs/set-get-trans.c    2000/12/29 18:28:18
@@ -22,6 +22,9 @@
 
 #include "netfs.h"
 
+/* Default implementations of the netfs_set_translator and
+   netfs_set_translator functions. */
+
 /* The user may define this function.  Attempt to set the passive
    translator record for FILE to ARGZ (of length ARGZLEN) for user
    CRED. */

Attachment: pgpooRgF2FYTx.pgp
Description: PGP signature


reply via email to

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