bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] libdiskfs: bugs


From: Neal H Walfield
Subject: [PATCH] libdiskfs: bugs
Date: Sun, 15 Apr 2001 18:27:36 +0200
User-agent: Mutt/1.3.15i

2001-04-14  Neal H Walfield  <neal@cs.uml.edu>

        * node-create.c (diskfs_create_node):  If we fail, set *NEWNODE
        to NULL; at least diskfs_S_dir_lookup depends on this behavior.

        * dir-chg.c (disk_S_dir_notice_changes): Check the return of
        malloc.
        * file-set-trans.c (diskfs_S_file_set_translator): Be
        consistent, use err not error.
        * init-init.c (_diskfs_control_clean): Spit out a warning if
        there are no outstanding send rights to our control port.
        * init-startup.c (diskfs_startup_diskfs): Use err, not errno so
        we can actually read this variable in a debugger.


diff --exclude CVS --exclude configure -urN 
hurd-20010412-snapshot/libdiskfs/node-create.c 
hurd-20010412/libdiskfs/node-create.c
--- hurd-20010412-snapshot/libdiskfs/node-create.c      Sat Oct 24 09:51:40 1998
+++ hurd-20010412/libdiskfs/node-create.c       Sun Apr 15 00:23:02 2001
@@ -1,5 +1,5 @@
 /* Making new files
-   Copyright (C) 1992, 1993, 1994, 1996, 1998 Free Software Foundation
+   Copyright (C) 1992,93,94,96,98,2001 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
@@ -38,7 +38,10 @@
   gid_t newgid;
 
   if (diskfs_check_readonly ())
-    return EROFS;
+    {
+      *newnode = NULL;
+      return EROFS;
+    }
 
   /* Make the node */
   err = diskfs_alloc_node (dir, mode, newnode);
@@ -46,6 +49,7 @@
     {
       if (name)
        diskfs_drop_dirstat (dir, ds);
+      *newnode = NULL;
       return err;
     }
 
@@ -100,6 +104,7 @@
       np->dn_stat.st_nlink = 0;
       if (name)
        diskfs_drop_dirstat (dir, ds);
+      *newnode = NULL;
       return err;
     }
 
@@ -115,5 +120,8 @@
          diskfs_nput (np);
        }
     }
+  if (err)
+    *newnode = NULL;
+    
   return err;
 }
diff --exclude CVS --exclude configure -urN 
hurd-20010412-snapshot/libdiskfs/dir-chg.c hurd-20010412/libdiskfs/dir-chg.c
--- hurd-20010412-snapshot/libdiskfs/dir-chg.c  Sun Apr  1 03:39:47 2001
+++ hurd-20010412/libdiskfs/dir-chg.c   Thu Apr 12 19:48:00 2001
@@ -44,11 +44,6 @@
       return err;
     }
   req = malloc (sizeof (struct modreq));
-  if (! req)
-    {
-      mutex_unlock (&np->lock);
-      return ENOMEM;
-    }
   req->port = notify;
   req->next = np->dirmod_reqs;
   np->dirmod_reqs = req;
diff --exclude CVS --exclude configure -urN 
hurd-20010412-snapshot/libdiskfs/file-set-trans.c 
hurd-20010412/libdiskfs/file-set-trans.c
--- hurd-20010412-snapshot/libdiskfs/file-set-trans.c   Sun Jan 24 03:42:58 1999
+++ hurd-20010412/libdiskfs/file-set-trans.c    Sun Apr 15 16:44:38 2001
@@ -1,5 +1,5 @@
 /* libdiskfs implementation of fs.defs: file_set_translator
-   Copyright (C) 1992, 93, 94, 95, 96, 99 Free Software Foundation, Inc.
+   Copyright (C) 1992,93,94,95,96,99,2001 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -31,7 +31,7 @@
                              fsys_t active)
 {
   struct node *np;
-  error_t error;
+  error_t err;
   mach_port_t control = MACH_PORT_NULL;
 
   if (!cred)
@@ -50,31 +50,31 @@
 
   mutex_lock (&np->lock);
 
-  error = fshelp_isowner (&np->dn_stat, cred->user);
-  if (error)
+  err = fshelp_isowner (&np->dn_stat, cred->user);
+  if (err)
     {
       mutex_unlock (&np->lock);
-      return error;
+      return err;
     }
 
   if (active_flags & FS_TRANS_SET)
     {
-      error = fshelp_fetch_control (&np->transbox, &control);
-      if (error)
+      err = fshelp_fetch_control (&np->transbox, &control);
+      if (err)
        {
          mutex_unlock (&np->lock);
-         return error;
+         return err;
        }
 
       if ((control != MACH_PORT_NULL) && ((active_flags & FS_TRANS_EXCL) == 0))
        {
          mutex_unlock (&np->lock);
-         error = fsys_goaway (control, killtrans_flags);
+         err = fsys_goaway (control, killtrans_flags);
          mach_port_deallocate (mach_task_self (), control);
-         if (error && (error != MIG_SERVER_DIED)
-             && (error != MACH_SEND_INVALID_DEST))
-           return error;
-         error = 0;
+         if (err && (err != MIG_SERVER_DIED)
+             && (err != MACH_SEND_INVALID_DEST))
+           return err;
+         err = 0;
          mutex_lock (&np->lock);
        }
       else if (control != MACH_PORT_NULL)
@@ -92,12 +92,12 @@
 
   if (active_flags & FS_TRANS_SET)
     {
-      error = fshelp_set_active (&np->transbox, active,
-                                active_flags & FS_TRANS_EXCL);
-      if (error)
+      err = fshelp_set_active (&np->transbox, active,
+                              active_flags & FS_TRANS_EXCL);
+      if (err)
        {
          mutex_unlock (&np->lock);
-         return error;
+         return err;
        }
     }
 
@@ -156,12 +156,12 @@
                    }
                  minor = strtol (arg, 0, 0);
 
-                 error = diskfs_validate_rdev_change (np,
-                                                      makedev (major, minor));
-                 if (error)
+                 err = diskfs_validate_rdev_change (np,
+                                                    makedev (major, minor));
+                 if (err)
                    {
                      mutex_unlock (&np->lock);
-                     return error;
+                     return err;
                    }
                  np->dn_stat.st_rdev = makedev (major, minor);
                }
@@ -178,32 +178,32 @@
                    }
 
                  if (diskfs_create_symlink_hook)
-                   error = (*diskfs_create_symlink_hook)(np, arg);
-                 if (!diskfs_create_symlink_hook || error == EINVAL)
+                   err = (*diskfs_create_symlink_hook)(np, arg);
+                 if (!diskfs_create_symlink_hook || err == EINVAL)
                    /* Store the argument in the file as the
                       target of the link */
-                   error = diskfs_node_rdwr (np, arg, 0, strlen (arg),
-                                             1, cred, 0);
-                 if (error)
+                   err = diskfs_node_rdwr (np, arg, 0, strlen (arg),
+                                           1, cred, 0);
+                 if (err)
                    {
                      mutex_unlock (&np->lock);
-                     return error;
+                     return err;
                    }
                }
              newmode = (np->dn_stat.st_mode & ~S_IFMT) | newmode;
-             error = diskfs_validate_mode_change (np, newmode);
-             if (!error)
+             err = diskfs_validate_mode_change (np, newmode);
+             if (!err)
                {
                  np->dn_stat.st_mode = newmode;
                  diskfs_node_update (np, 1);
                }
              mutex_unlock (&np->lock);
-             return error;
+             return err;
            }
        }
-      error = diskfs_set_translator (np, passive, passivelen, cred);
+      err = diskfs_set_translator (np, passive, passivelen, cred);
     }
 
   mutex_unlock (&np->lock);
-  return error;
+  return err;
 }
diff --exclude CVS --exclude configure -urN 
hurd-20010412-snapshot/libdiskfs/init-init.c hurd-20010412/libdiskfs/init-init.c
--- hurd-20010412-snapshot/libdiskfs/init-init.c        Sun Apr  1 03:39:49 2001
+++ hurd-20010412/libdiskfs/init-init.c Sun Apr 15 00:28:06 2001
@@ -24,6 +24,7 @@
 #include <hurd/fsys.h>
 #include <stdio.h>
 #include <maptime.h>
+#include <error.h>
 
 mach_port_t diskfs_default_pager;
 mach_port_t diskfs_auth_server_port;
@@ -103,5 +104,7 @@
 {
   spin_lock (&_diskfs_control_lock);
   _diskfs_ncontrol_ports--;
+  if (_diskfs_ncontrol_ports == 0)
+    error (0, 0, "No outstanding control ports.");
   spin_unlock (&_diskfs_control_lock);
 }
diff --exclude CVS --exclude configure -urN 
hurd-20010412-snapshot/libdiskfs/init-startup.c 
hurd-20010412/libdiskfs/init-startup.c
--- hurd-20010412-snapshot/libdiskfs/init-startup.c     Fri Mar 17 20:40:25 2000
+++ hurd-20010412/libdiskfs/init-startup.c      Sat Apr 14 13:51:05 2001
@@ -32,6 +32,7 @@
 mach_port_t
 diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
 {
+  error_t err;
   mach_port_t realnode, right;
   struct port_info *newpi;
 
@@ -39,7 +40,6 @@
     {
       /* The boot options requested we change to a subdirectory
         and treat that as the root of the filesystem.  */
-      error_t err;
       struct node *np, *old;
       struct protid *rootpi;
 
@@ -85,21 +85,19 @@
 
   if (bootstrap != MACH_PORT_NULL)
     {
-      errno = ports_create_port (diskfs_control_class, diskfs_port_bucket,
-                                sizeof (struct port_info), &newpi);
-      if (! errno)
+      err = ports_create_port (diskfs_control_class, diskfs_port_bucket,
+                              sizeof (struct port_info), &newpi);
+      if (! err)
        {
          right = ports_get_send_right (newpi);
-         errno = fsys_startup (bootstrap, flags, right,
-                               MACH_MSG_TYPE_COPY_SEND, &realnode);
+         err = fsys_startup (bootstrap, flags, right,
+                             MACH_MSG_TYPE_COPY_SEND, &realnode);
          mach_port_deallocate (mach_task_self (), right);
          ports_port_deref (newpi);
        }
-      if (errno)
-       {
-         perror ("Translator startup failure: fsys_startup");
-         exit (1);
-       }
+      if (err)
+        error (1, err, "Translator startup failure: fsys_startup");
+
       mach_port_deallocate (mach_task_self (), bootstrap);
       _diskfs_ncontrol_ports++;
 

Attachment: pgpoYuw2b0j9s.pgp
Description: PGP signature


reply via email to

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