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.
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) {
if (mount_point == NULL ||
mount_point[0] != '/') {
fprintf(stderr, "%s: unknown mount point %s\n",
- progname, argv[2]);
+ progname, mount_point ? : "");
exit(1);
}
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) {