From b8b6a251c372b134e66d0f436bf2c6231cc1c055 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 20 Mar 2007 12:53:32 +1100 Subject: [PATCH 1/1] mount.nfs - make sure program name in error message is correct. getopt_long uses argv[0] in error messages. So it it is given argv+2 for example, we need to make sure that argv[2] has the correct program name. --- utils/mount/mount.c | 3 ++- utils/mount/nfsumount.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/mount/mount.c b/utils/mount/mount.c index 71a8737..9ae66f0 100644 --- a/utils/mount/mount.c +++ b/utils/mount/mount.c @@ -350,6 +350,7 @@ int main(int argc, char *argv[]) spec = argv[1]; mount_point = argv[2]; + argv[2] = argv[0]; /* so that getopt error messages are correct */ while ((c = getopt_long (argc - 2, argv + 2, "rt:vVwfno:hs", longopts, NULL)) != -1) { switch (c) { @@ -448,7 +449,7 @@ int main(int argc, char *argv[]) if (mount_point == NULL || mount_point[0] != '/') { fprintf(stderr, "%s: unknown mount point %s\n", - progname, argv[2]); + progname, mount_point ? : ""); exit(1); } diff --git a/utils/mount/nfsumount.c b/utils/mount/nfsumount.c index e101105..81d0d3a 100644 --- a/utils/mount/nfsumount.c +++ b/utils/mount/nfsumount.c @@ -288,6 +288,7 @@ int nfsumount(int argc, char *argv[]) argv += 1; argc -= 1; + argv[0] = argv[-1]; /* So that getopt error messages are correct */ while ((c = getopt_long (argc, argv, "fvnrlh", umount_longopts, NULL)) != -1) { -- 2.39.2