svn commit: trunk/busybox: include scripts util-linux

vda at busybox.net vda at busybox.net
Sat Feb 16 23:28:45 UTC 2008


Author: vda
Date: 2008-02-16 15:28:42 -0800 (Sat, 16 Feb 2008)
New Revision: 21042

Log:
mount: make -f work even without mtab support
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)



Modified:
   trunk/busybox/include/usage.h
   trunk/busybox/scripts/defconfig
   trunk/busybox/util-linux/Config.in
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2008-02-16 22:58:56 UTC (rev 21041)
+++ trunk/busybox/include/usage.h	2008-02-16 23:28:42 UTC (rev 21042)
@@ -2449,8 +2449,10 @@
        "Mount a filesystem. Filesystem autodetection requires /proc be mounted." \
        "\n\nOptions:\n" \
        "	-a		Mount all filesystems in fstab\n" \
+	USE_FEATURE_MOUNT_FAKE( \
+       "	-f		"USE_FEATURE_MTAB_SUPPORT("Update /etc/mtab, but ")"don't mount\n" \
+	) \
 	USE_FEATURE_MTAB_SUPPORT( \
-       "	-f		Update /etc/mtab, but don't mount\n" \
        "	-n		Don't update /etc/mtab\n" \
 	) \
        "	-r		Read-only mount\n" \

Modified: trunk/busybox/scripts/defconfig
===================================================================
--- trunk/busybox/scripts/defconfig	2008-02-16 22:58:56 UTC (rev 21041)
+++ trunk/busybox/scripts/defconfig	2008-02-16 23:28:42 UTC (rev 21042)
@@ -478,6 +478,7 @@
 # CONFIG_FEATURE_MOUNT_HELPERS is not set
 CONFIG_FEATURE_MOUNT_NFS=y
 CONFIG_FEATURE_MOUNT_CIFS=y
+CONFIG_FEATURE_MOUNT_FAKE=y
 CONFIG_FEATURE_MOUNT_FLAGS=y
 CONFIG_FEATURE_MOUNT_FSTAB=y
 CONFIG_PIVOT_ROOT=y

Modified: trunk/busybox/util-linux/Config.in
===================================================================
--- trunk/busybox/util-linux/Config.in	2008-02-16 22:58:56 UTC (rev 21041)
+++ trunk/busybox/util-linux/Config.in	2008-02-16 23:28:42 UTC (rev 21042)
@@ -386,6 +386,13 @@
 	  NFS filesystems.  Most people using BusyBox will also want to enable
 	  the 'mount' utility.
 
+config FEATURE_MOUNT_FAKE
+	bool "mount -f option"
+	default n
+	depends on MOUNT
+	help
+	  Enable support for faking a file system mount.
+
 config FEATURE_MOUNT_HELPERS
 	bool "Support mount helpers"
 	default n
@@ -542,6 +549,7 @@
 	bool "Support for the old /etc/mtab file"
 	default n
 	depends on MOUNT || UMOUNT
+	select FEATURE_MOUNT_FAKE
 	help
 	  Historically, Unix systems kept track of the currently mounted
 	  partitions in the file "/etc/mtab".  These days, the kernel exports

Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2008-02-16 22:58:56 UTC (rev 21041)
+++ trunk/busybox/util-linux/mount.c	2008-02-16 23:28:42 UTC (rev 21042)
@@ -54,6 +54,35 @@
 	MOUNT_NOAUTO = (1<<29),
 	MOUNT_SWAP   = (1<<30),
 };
+
+
+#define OPTION_STR "o:t:rwanfvsi"
+enum {
+	OPT_o = (1 << 0),
+	OPT_t = (1 << 1),
+	OPT_r = (1 << 2),
+	OPT_w = (1 << 3),
+	OPT_a = (1 << 4),
+	OPT_n = (1 << 5),
+	OPT_f = (1 << 6),
+	OPT_v = (1 << 7),
+	OPT_s = (1 << 8),
+	OPT_i = (1 << 9),
+};
+
+#if ENABLE_FEATURE_MTAB_SUPPORT
+#define useMtab (!(option_mask32 & OPT_n))
+#else
+#define useMtab 0
+#endif
+
+#if ENABLE_FEATURE_MOUNT_FAKE
+#define fakeIt (option_mask32 & OPT_f)
+#else
+#define fakeIt 0
+#endif
+
+
 // TODO: more "user" flag compatibility.
 // "user" option (from mount manpage):
 // Only the user that mounted a filesystem can unmount it again.
@@ -288,14 +317,6 @@
 void delete_block_backed_filesystems(void);
 #endif
 
-#if ENABLE_FEATURE_MTAB_SUPPORT
-static int useMtab = 1;
-static int fakeIt;
-#else
-#define useMtab 0
-#define fakeIt 0
-#endif
-
 // Perform actual mount of specific filesystem at specific location.
 // NB: mp->xxx fields may be trashed on exit
 static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
@@ -346,7 +367,7 @@
 	/* If the mount was successful, and we're maintaining an old-style
 	 * mtab file by hand, add the new entry to it now. */
  mtab:
-	if (ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
+	if (useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
 		char *fsname;
 		FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
 		const char *option_str = mount_option_str;
@@ -1657,17 +1678,10 @@
 
 	// Parse remaining options
 
-	opt = getopt32(argv, "o:t:rwanfvsi", &opt_o, &fstype);
-	if (opt & 0x1) append_mount_options(&cmdopts, opt_o); // -o
-	//if (opt & 0x2) // -t
-	if (opt & 0x4) append_mount_options(&cmdopts, "ro"); // -r
-	if (opt & 0x8) append_mount_options(&cmdopts, "rw"); // -w
-	//if (opt & 0x10) // -a
-	if (opt & 0x20) USE_FEATURE_MTAB_SUPPORT(useMtab = 0); // -n
-	if (opt & 0x40) USE_FEATURE_MTAB_SUPPORT(fakeIt = 1); // -f
-	//if (opt & 0x80) // -v: verbose (ignore)
-	//if (opt & 0x100) // -s: sloppy (ignore)
-	//if (opt & 0x200) // -i: don't call mount.<fstype> (ignore)
+	opt = getopt32(argv, OPTION_STR, &opt_o, &fstype);
+	if (opt & OPT_o) append_mount_options(&cmdopts, opt_o); // -o
+	if (opt & OPT_r) append_mount_options(&cmdopts, "ro"); // -r
+	if (opt & OPT_w) append_mount_options(&cmdopts, "rw"); // -w
 	argv += optind;
 	argc -= optind;
 




More information about the busybox-cvs mailing list