bug-hurd
[Top][All Lists]
Advanced

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

[patch] setting the fsid on a bootstrap file system


From: Neal H Walfield
Subject: [patch] setting the fsid on a bootstrap file system
Date: Wed, 21 Nov 2001 13:39:28 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1

We cannot set the fsid of a boot file system to its uid as, at least
initially, there is no proc server.  The current work around is to
wait until we need the fsid and then set it.  The implication is that
every time we need the fsid, we must also check to see if it has been
set.  Although this is not a lot of overhead, this is far from
elegant, especially since we have a function such as
diskfs_boot_filesystem.

My solution is to check in main (where all of the other initialization
happens) if the file system is a boot file system and if so, set fsid,
a new global variable, to 0, and otherwise, set it to the result of
getuid ().  This is the same logic that we were using before.

This patch does this for both the ext2fs and ufs file systems.  It
also makes explicit in the comment for diskfs_boot_filesystem () that
it cannot be called until the arguments have been parsed by, e.g. a
call to diskfs_init_main.

Additionally, this patch fixes a few superfluous global zero
initializers.

I have tested the code in ext2fs, however, as I do not have any ufs
partitions, I have only made sure that the ufs code compiles.  But, I
doubt that there will be any problems -- the changes are nearly
identical to those made in ext2fs.


libdiskfs:

2001-11-20  Neal H Walfield  <neal@cs.uml.edu>

        * diskfs.h (diskfs_boot_filesystem): Documentation fix.


ext2fs:

2001-11-20  Neal H Walfield  <neal@cs.uml.edu>

        * ext2fs.h (fsid): New global variable.
        * inode.c (read_disknode): Do not initialize fsid here ...
        * ext2fs.c (main): ... do it here.

        (diskfs_synchronous): Zero initializer is superfluous.
        (store): Likewise.
        (store_parsed): Likewise.
        (diskfs_disk_name): Likewise.
        (ext2_debug_flag): Likewise.


ufs:

2001-11-20  Neal H Walfield  <neal@cs.uml.edu>

        * ufs.h (fsid): New global variable.
        * inode.c (read_disknode): Do not initialize fsid here ...
        * main.c (main): ... do it here.


Index: libdiskfs/diskfs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/diskfs.h,v
retrieving revision 1.92
diff -u -p -r1.92 diskfs.h
--- libdiskfs/diskfs.h  2001/08/20 22:44:13     1.92
+++ libdiskfs/diskfs.h  2001/11/21 12:09:23
@@ -149,9 +149,11 @@ extern mach_port_t diskfs_fsys_identity;
    file systems, to give the procserver.  */
 extern char **diskfs_argv;
 
-/* When this is a bootstrap filesystem, the multiboot kernel command line
-   passed from the kernel.  If not a bootstrap filesystem, it is 0, so it
-   can be used to distinguish between the two cases.  */
+/* When this is a bootstrap filesystem, the multiboot kernel command
+   line passed from the kernel.  If not a bootstrap filesystem, it is
+   0.  As such, it can be used to distinguish between the two cases.
+   Note: these is only valid after the arguements have been parsed by,
+   for example, diskfs_init_main.  */
 extern const char *diskfs_boot_command_line;
 #define diskfs_boot_filesystem()       (diskfs_boot_command_line != 0)
 
Index: ext2fs/ext2fs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ext2fs.c,v
retrieving revision 1.53
diff -u -p -r1.53 ext2fs.c
--- ext2fs/ext2fs.c     2001/01/08 22:33:11     1.53
+++ ext2fs/ext2fs.c     2001/11/21 12:09:24
@@ -47,17 +47,17 @@ char *diskfs_server_name = "ext2fs";
 char *diskfs_server_version = HURD_VERSION;
 char *diskfs_extra_version = "GNU Hurd; ext2 " EXT2FS_VERSION;
 
-int diskfs_synchronous = 0;
+int diskfs_synchronous;
 
 struct node *diskfs_root_node;
 
-struct store *store = 0;
-struct store_parsed *store_parsed = 0;
+struct store *store;
+struct store_parsed *store_parsed;
 
-char *diskfs_disk_name = 0;
+char *diskfs_disk_name;
 
 #ifdef EXT2FS_DEBUG
-int ext2_debug_flag = 0;
+int ext2_debug_flag;
 #endif
 
 /* Ext2fs-specific options.  */
@@ -186,6 +186,12 @@ main (int argc, char **argv)
   get_hypermetadata();
 
   inode_init ();
+
+  if (diskfs_boot_filesystem ())
+    /* We cannot call getuid until there is a proc server!  */
+    fsid = 0;
+  else
+    fsid = getuid ();
 
   /* Set diskfs_root_node to the root inode. */
   err = diskfs_cached_lookup (EXT2_ROOT_INO, &diskfs_root_node);
Index: ext2fs/ext2fs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ext2fs.h,v
retrieving revision 1.69
diff -u -p -r1.69 ext2fs.h
--- ext2fs/ext2fs.h     1999/10/03 10:23:26     1.69
+++ ext2fs/ext2fs.h     2001/11/21 12:09:25
@@ -1,8 +1,8 @@
 /* Common definitions for the ext2 filesystem translator
 
-   Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1999, 2001 Free Software Foundation, Inc.
 
-   Written by Miles Bader <miles@gnu.ai.mit.edu>
+   Written by Miles Bader <miles@gnu.org>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -203,6 +203,9 @@ void allow_pager_softrefs (struct node *
 void flush_node_pager (struct node *node);
 
 /* ---------------------------------------------------------------- */
+
+/* The fsid.  */
+int fsid;
 
 /* The physical media.  */
 extern struct store *store;
Index: ufs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/inode.c,v
retrieving revision 1.57
diff -u -p -r1.57 inode.c
--- ufs/inode.c 2001/08/10 04:43:01     1.57
+++ ufs/inode.c 2001/11/21 12:09:30
@@ -212,7 +223,6 @@ diskfs_new_hardrefs (struct node *np)
 static error_t
 read_disknode (struct node *np)
 {
-  static int fsid, fsidset;
   struct stat *st = &np->dn_stat;
   struct dinode *di = dino (np->dn->number);
   error_t err;
@@ -220,12 +230,6 @@ read_disknode (struct node *np)
   err = diskfs_catch_exception ();
   if (err)
     return err;
-
-  if (! fsidset)
-    {
-      fsid = getpid ();
-      fsidset = 1;
-    }
 
   st->st_fstype = FSTYPE_UFS;
   st->st_fsid = fsid;
Index: ufs/main.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/main.c,v
retrieving revision 1.49
diff -u -p -r1.49 main.c
--- ufs/main.c  2001/01/08 22:33:11     1.49
+++ ufs/main.c  2001/11/21 12:09:30
@@ -184,6 +184,12 @@ main (int argc, char **argv)
 
   inode_init ();
 
+  if (diskfs_boot_filesystem ())
+    /* We cannot call getuid until there is a proc server!  */
+    fsid = 0;
+  else
+    fsid = getuid ();
+
   /* Find our root node.  */
   warp_root ();
 
Index: ufs/ufs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/ufs.h,v
retrieving revision 1.37
diff -u -p -r1.37 ufs.h
--- ufs/ufs.h   2001/10/01 16:37:27     1.37
+++ ufs/ufs.h   2001/11/21 12:09:30
@@ -90,6 +90,9 @@ struct user_pager_info
 
 #include <hurd/diskfs-pager.h>
 
+/* The fsid.  */
+int fsid;
+
 /* The physical media.  */
 extern struct store *store;
 /* What the user specified.  */



reply via email to

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