]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/nfsumount.c
mount.nfs - make sure program name in error message is correct.
[nfs-utils.git] / utils / mount / nfsumount.c
index 1decf07d7debd2bc2fdf857c9275082b90b73f0c..81d0d3a72c4ea5ca1a1230e3991b33fc38f38164 100644 (file)
@@ -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) {
 
@@ -313,6 +314,10 @@ int nfsumount(int argc, char *argv[])
                        return 0;
                }
        }
+       if (optind != argc) {
+               umount_usage();
+               return 0;
+       }
        
        if (spec == NULL || (*spec != '/' && strchr(spec,':') == NULL)) {
                printf(_("umount: %s: not found\n"), spec);
@@ -326,6 +331,13 @@ int nfsumount(int argc, char *argv[])
        if (!mc && verbose)
                printf(_("Could not find %s in mtab\n"), spec);
 
+       if (mc && strcmp(mc->m.mnt_type, "nfs") != 0 &&
+           strcmp(mc->m.mnt_type, "nfs4") != 0) {
+               fprintf(stderr, "umount.nfs: %s on %s it not an nfs filesystem\n",
+                       mc->m.mnt_fsname, mc->m.mnt_dir);
+               exit(1);
+       }
+
        if (getuid() != 0) {
                /* only permitted if "user=" or "users" is in mount options */
                if (!mc) {