svn commit: trunk/busybox/util-linux

vda at busybox.net vda at busybox.net
Mon Feb 18 13:05:47 UTC 2008


Author: vda
Date: 2008-02-18 05:05:38 -0800 (Mon, 18 Feb 2008)
New Revision: 21051

Log:
mount: with -vv -f, say what mount() calls we were going to make

 782357     728    7476  790561   c1021 busybox_old
 782429     728    7476  790633   c1069 busybox_unstripped



Modified:
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2008-02-18 12:07:49 UTC (rev 21050)
+++ trunk/busybox/util-linux/mount.c	2008-02-18 13:05:38 UTC (rev 21051)
@@ -216,7 +216,11 @@
 };
 #define G (*(struct globals*)&bb_common_bufsiz1)
 #define nfs_mount_version (G.nfs_mount_version)
+#if ENABLE_FEATURE_MOUNT_VERBOSE
 #define verbose           (G.verbose          )
+#else
+#define verbose           0
+#endif
 #define fslist            (G.fslist           )
 #define getmntent_buf     (G.getmntent_buf    )
 
@@ -231,9 +235,10 @@
 	errno = 0;
 	rc = mount(source, target, filesystemtype, mountflags, data);
 	if (verbose >= 2)
-		bb_perror_msg("mount('%s','%s','%s',0x%08lx,'%s'):%d",
-				source, target, filesystemtype,
-				mountflags, (char*)data, rc);
+		bb_perror_msg("would do mount('%s','%s','%s',0x%08lx,'%s'):%d"
+				+ (sizeof("would do ")-1),
+			source, target, filesystemtype,
+			mountflags, (char*)data, rc);
 	return rc;
 }
 #else
@@ -274,9 +279,9 @@
 
 /* Use the mount_options list to parse options into flags.
  * Also return list of unrecognized options if unrecognized!=NULL */
-static int parse_mount_options(char *options, char **unrecognized)
+static long parse_mount_options(char *options, char **unrecognized)
 {
-	int flags = MS_SILENT;
+	long flags = MS_SILENT;
 
 	// Loop through options
 	for (;;) {
@@ -360,11 +365,17 @@
 
 // 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)
+static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)
 {
 	int rc = 0;
 
-	if (fakeIt) goto mtab;
+	if (fakeIt) {
+		if (verbose >= 2)
+			bb_error_msg("would do mount('%s','%s','%s',0x%08lx,'%s')",
+				mp->mnt_fsname, mp->mnt_dir, mp->mnt_type,
+				vfsflags, filteropts);
+		goto mtab;
+	}
 
 	// Mount, with fallback to read-only if necessary.
 	for (;;) {
@@ -898,7 +909,7 @@
 }
 
 // NB: mp->xxx fields may be trashed on exit
-static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts)
+static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
 {
 	CLIENT *mclient;
 	char *hostname;
@@ -1507,7 +1518,7 @@
 #else /* !ENABLE_FEATURE_MOUNT_NFS */
 
 /* Never called. Call should be optimized out. */
-int nfsmount(struct mntent *mp, int vfsflags, char *filteropts);
+int nfsmount(struct mntent *mp, long vfsflags, char *filteropts);
 
 #endif /* !ENABLE_FEATURE_MOUNT_NFS */
 
@@ -1516,7 +1527,8 @@
 // NB: mp->xxx fields may be trashed on exit
 static int singlemount(struct mntent *mp, int ignore_busy)
 {
-	int rc = -1, vfsflags;
+	int rc = -1;
+	long vfsflags;
 	char *loopFile = 0, *filteropts = 0;
 	llist_t *fl = 0;
 	struct stat st;
@@ -1702,9 +1714,8 @@
 	unsigned opt;
 	struct mntent mtpair[2], *mtcur = mtpair;
 	SKIP_DESKTOP(const int nonroot = 0;)
-	USE_DESKTOP( int nonroot = (getuid() != 0);)
 
-	sanitize_env_if_suid();
+	USE_DESKTOP( int nonroot = ) sanitize_env_if_suid();
 
 	// Parse long options, like --bind and --move.  Note that -o option
 	// and --option are synonymous.  Yes, this means --remount,rw works.
@@ -1774,7 +1785,7 @@
 		goto clean_up;
 	}
 
-	i = parse_mount_options(cmdopts, 0);
+	i = parse_mount_options(cmdopts, 0); // FIXME: should be "long", not "int"
 	if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags
 		bb_error_msg_and_die(must_be_root);
 




More information about the busybox-cvs mailing list