bug-hurd
[Top][All Lists]
Advanced

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

mtab: libdiskfs / ext2fs support changes


From: David Walter
Subject: mtab: libdiskfs / ext2fs support changes
Date: Mon, 09 Sep 2002 22:45:31 -0400

libdiskfs patch:

The previously posted mtab should accept the arguments from the
following patch to add support for the option --mntpath=MNTPATH

The following is a sample sequence:

/mnt$ export DEVICE=17; settrans -fgcap /mnt/$DEVICE /hurd/ext2fs \
       /dev/hd0s$DEVICE --mntpath=/mnt/$DEVICE 
/mnt$ showtrans -a -d /mnt/17
 /hurd/ext2fs /dev/hd0s17 --mntpath=/mnt/17 --writable
*/hurd/ext2fs --writable --mntpath=/mnt/17 /dev/hd0s17
/mnt$ fsysopts /mnt/17
/hurd/ext2fs --writable --mntpath=/mnt/17 /dev/hd0s17

/mnt$ cat /var/run/mtab 
hd0s15 / --writable,--store-type=typed,device:hd0s15  0 0
hd0s11 /home --writable,--mntpath=/home,/dev/hd0s11  0 0
hd0s13 /opt --writable,--mntpath=/opt,/dev/hd0s13  0 0
hd0s12 /mnt/12 --readonly,--mntpath=/mnt/12,/dev/hd0s12  0 0
hd0s5 /mnt/5 --readonly,--mntpath=/mnt/5,/dev/hd0s5  0 0
hd0s16 /mnt/16 --writable,--mntpath=/mnt/16,/dev/hd0s16  0 0
hd0s17 /mnt/17 --writable,--mntpath=/mnt/17,/dev/hd0s17  0 0


For clarity the patch for libdiskfs and ext2fs are in separate
messages.

cvs server: Diffing .
Index: ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/ChangeLog,v
retrieving revision 1.182
diff --unified -w -i -r1.182 ChangeLog
--- ChangeLog   27 Jun 2002 19:19:13 -0000      1.182
+++ ChangeLog   10 Sep 2002 02:25:01 -0000
@@ -1,3 +1,25 @@
+2002-09-09  David Walter  <address@hidden>
+
+       * opts-append-std.c (diskfs_append_std_options): display mntpath
+       option.
+
+       * notify-mtab.c (diskfs_notify_mtab): function diskfs_notify_mtab
+       takes a mount point and writes it to _PATH_MOUNTED, if arg is null
+       use previous value because at startup the entry can't be written
+       to mtab until the filesystem is active, so it defers write until
+       filesystem startup
+
+       * priv.h: added global symbol diskfs_mount_point: the path this is
+       mounted on.
+
+       * opts-std-startup.c (parse_startup_opt): added include <paths.h>
+       for _PATH_MOUNTED added call to diskfs_notify_mtab
+
+       * opts-std-runtime.c (parse_opt): added include <paths.h> for
+       _PATH_MOUNTED and call to new routine diskfs_notify_mtab
+
+       * Makefile (OTHERSRCS): added notify-mtab.c
+       
 2002-06-26  Marcus Brinkmann  <address@hidden>
 
        * Makefile (DIST_FILES): Variable removed.
Index: Makefile
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/Makefile,v
retrieving revision 1.71
diff --unified -w -i -r1.71 Makefile
--- Makefile    27 Jun 2002 19:19:13 -0000      1.71
+++ Makefile    10 Sep 2002 02:25:01 -0000
@@ -51,7 +51,9 @@
        remount.c console.c disk-pager.c \
        name-cache.c direnter.c dirrewrite.c dirremove.c lookup.c dead-name.c \
        validate-mode.c validate-group.c validate-author.c validate-flags.c \
-       validate-rdev.c validate-owner.c extra-version.c
+       validate-rdev.c validate-owner.c extra-version.c \
+   notify-mtab.c 
+
 SRCS = $(OTHERSRCS) $(FSSRCS) $(IOSRCS) $(FSYSSRCS) $(IFSOCKSRCS)
 LCLHDRS = diskfs.h priv.h lithp.h fsmutations.h diskfs-pager.h fhandle.h
 installhdrs = diskfs.h diskfs-pager.h
Index: diskfs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/diskfs.h,v
retrieving revision 1.98
diff --unified -w -i -r1.98 diskfs.h
--- diskfs.h    27 Jun 2002 19:19:13 -0000      1.98
+++ diskfs.h    10 Sep 2002 02:25:03 -0000
@@ -973,4 +973,17 @@
 /* Make errors go somewhere reasonable.  */
 void diskfs_console_stdio ();
 
+/*
+  diskfs_notify_mtab: write the path of a translator to the mount
+  table
+
+  This  is not a  boot option.   Notice that  every running  system is
+  assumed by /hurd/mtab to have a root which is automagically inserted
+  in mtab at startup.
+
+  A NULL arg uses the current value of diskfs_mount_point otherwise
+  diskfs_mount_point is set to path and written to _PATH_MOUNTED */
+
+void diskfs_notify_mtab (char* path);
+
 #endif /* hurd/diskfs.h */
Index: opts-append-std.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/opts-append-std.c,v
retrieving revision 1.10
diff --unified -w -i -r1.10 opts-append-std.c
--- opts-append-std.c   8 May 2002 09:56:54 -0000       1.10
+++ opts-append-std.c   10 Sep 2002 02:25:03 -0000
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <argz.h>
+#include <paths.h>
 
 #include "priv.h"
 
@@ -61,6 +62,15 @@
            }
        }
     }
+  if (!err)
+  {
+     if (diskfs_mount_point)
+     {
+        char*buf=0;
+        asprintf(&buf, "--mntpath=%s", diskfs_mount_point);
+        err = argz_add (argz, argz_len, buf);
+     }
+  }
 
   return err;
 }
Index: opts-common.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/opts-common.c,v
retrieving revision 1.6
diff --unified -w -i -r1.6 opts-common.c
--- opts-common.c       1 May 2002 03:00:44 -0000       1.6
+++ opts-common.c       10 Sep 2002 02:25:03 -0000
@@ -22,7 +22,7 @@
 
 #include <argp.h>
 #include "priv.h"
-
+#include <paths.h>
 const struct argp_option diskfs_common_options[] =
 {
   {"readonly", 'r', 0, 0, "Never write to disk or allow opens for writing"},
Index: opts-std-runtime.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/opts-std-runtime.c,v
retrieving revision 1.11
diff --unified -w -i -r1.11 opts-std-runtime.c
--- opts-std-runtime.c  1 May 2002 03:00:44 -0000       1.11
+++ opts-std-runtime.c  10 Sep 2002 02:25:03 -0000
@@ -19,6 +19,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 #include <argp.h>
+#include <paths.h>
 
 #include "priv.h"
 
@@ -106,6 +107,7 @@
     case OPT_ATIME: h->noatime = 0; break;
     case OPT_NO_INHERIT_DIR_GROUP: h->noinheritdirgroup = 1; break;
     case OPT_INHERIT_DIR_GROUP: h->noinheritdirgroup = 0; break;
+    case 'm': diskfs_notify_mtab (arg); break;
     case 'n': h->sync_interval = 0; h->sync = 0; break;
     case 's':
       if (arg)
Index: opts-std-startup.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/opts-std-startup.c,v
retrieving revision 1.20
diff --unified -w -i -r1.20 opts-std-startup.c
--- opts-std-startup.c  1 May 2002 03:00:44 -0000       1.20
+++ opts-std-startup.c  10 Sep 2002 02:25:04 -0000
@@ -23,6 +23,7 @@
 #include <argp.h>
 #include <hurd/store.h>
 #include <hurd/paths.h>
+#include <paths.h>
 #include "priv.h"
 
 const char *diskfs_boot_command_line;
@@ -34,6 +35,8 @@
 
 mach_port_t diskfs_exec_server_task = MACH_PORT_NULL;
 
+char *diskfs_mount_point=0;
+
 /* ---------------------------------------------------------------- */
 
 #define OPT_HOST_PRIV_PORT     (-1)
@@ -66,7 +69,7 @@
   {"host-priv-port",     OPT_HOST_PRIV_PORT,     "PORT"},
   {"device-master-port", OPT_DEVICE_MASTER_PORT, "PORT"},
   {"exec-server-task",   OPT_EXEC_SERVER_TASK,   "PORT"},
-
+  {"mntpath", 'm', "PATH_MOUNTED", 0, "write PATH_MOUNTED to " _PATH_MOUNTED },
   {0}
 };
 
@@ -96,6 +99,7 @@
       diskfs_synchronous = 0;
       diskfs_default_sync_interval = 0;
       break;
+    case 'm': diskfs_notify_mtab(arg); break;
 
       /* Boot options */
     case OPT_DEVICE_MASTER_PORT:
Index: priv.h
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/priv.h,v
retrieving revision 1.45
diff --unified -w -i -r1.45 priv.h
--- priv.h      1 May 2002 03:00:44 -0000       1.45
+++ priv.h      10 Sep 2002 02:25:04 -0000
@@ -132,5 +132,5 @@
 /* Bits that are turned off after open */
 #define OPENONLY_STATE_MODES \
   (O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS|O_NONBLOCK|O_EXLOCK|O_SHLOCK)
-
+extern char * diskfs_mount_point;
 #endif
Index: notify-mtab.c
===================================================================
--- notify-mtab.c.orig  Mon Sep  9 22:00:25 2002
+++ notify-mtab.c       Mon Sep  9 12:31:16 2002
@@ -0,0 +1,41 @@
+/* notify-mtab: write the path of this translator to _PATH_MOUNTED
+
+   Copyright (C) 2002 Free Software Foundation
+
+   Written by David Walter <address@hidden>
+
+   This program 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.
+
+   This program 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define _GNU_SOURCE 1
+
+#include <stdio.h>
+#include <paths.h>
+#include "priv.h"
+void diskfs_notify_mtab(char*path)
+{
+   if (path)
+   {
+      if (diskfs_mount_point)
+         free (diskfs_mount_point);
+      diskfs_mount_point = strdup(path);
+   }
+   FILE* mtab = fopen(_PATH_MOUNTED, "a+");
+   if(mtab)
+   {
+      fprintf(mtab, "%s\n", diskfs_mount_point);
+      fclose(mtab);
+   }
+}
+

-- 
/^\
\ /     ASCII RIBBON CAMPAIGN
 X        AGAINST HTML MAIL
/ \





reply via email to

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