From: Neil Brown Date: Tue, 20 Mar 2007 01:53:32 +0000 (+1100) Subject: mount.nfs - make sure program name in error message is correct. X-Git-Tag: nfs-utils-1-1-0-rc1~26 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=b8b6a251c372b134e66d0f436bf2c6231cc1c055;p=nfs-utils.git 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. --- 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) {