Skip to contentSkip to conversation

nfs-utils: Don't hard code source and destination args

PATCH New Prem Karat 1 participant 1 message Jun 28, 2011

Subsystems (2)
lore
Share & tools
lore

Prem Karat

author
#0 lore raw

PATCH 1/1 nfs-utils: Don't hard code source and destination args

Currently souce and destination parameters should be passed as first and second paramter while using mount.nfs. This patch allows them to be passed anywhere while mounting.

Current functionality is
mount.nfs source destn -o <options>
This patch will allow to do this
mount.nfs -o <options> source destn
or
mount.nfs -o <options> source -o <options> destn

---
 utils/mount/mount.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
utils/mount/mount.c +9 -4
index f3f0a83..62115bb 100644
@@ -374,7 +374,7 @@ static int try_mount(char *spec, char *mount_point, int flags,
 int main(int argc, char *argv[])
 {
 	int c, flags = 0, mnt_err = 1, fake = 0;
-	char *spec, *mount_point, *fs_type = "nfs";
+	char *spec = NULL, *mount_point = NULL, *fs_type = "nfs";
 	char *extra_opts = NULL, *mount_opts = NULL;
 	uid_t uid = getuid();
 
@@ -398,9 +398,6 @@ int main(int argc, char *argv[])
 		exit(EX_USAGE);
 	}
 
-	spec = argv[1];
-	mount_point = argv[2];
-
 	mount_config_init(progname);
 
 	argv[2] = argv[0]; /* so that getopt error messages are correct */
@@ -447,6 +444,14 @@ int main(int argc, char *argv[])
 	if (optind != argc - 2) {
 		mount_usage();
 		goto out_usage;
+	} else {
+		while (optind < argc) {
+			if (!spec)
+				spec = argv[optind];
+			else
+				mount_point = argv[optind];
+			optind++;
+		}
 	}
 
 	if (strcmp(progname, "mount.nfs4") == 0)
Signature · 8 lines
1.7.4

-- 
Cheers,
Prem
Linux Technology Center,
IBM Systems & Technology Labs
DID: 41776362