]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Support -s option to ignore unknown options (sloppy)
authorNeil Brown <neilb@suse.de>
Fri, 16 Mar 2007 06:02:42 +0000 (17:02 +1100)
committerNeil Brown <neilb@suse.de>
Fri, 16 Mar 2007 06:02:42 +0000 (17:02 +1100)
utils/mount/mount.c
utils/mount/nfs4mount.c
utils/mount/nfsmount.c

index 639ff4bcb9999335506828d70ce8df02978c1d7e..7d58ef67ce36a023969d53d8f82769e9ec2e0c1a 100644 (file)
@@ -43,6 +43,7 @@ char *progname;
 int nomtab;
 int verbose;
 int mounttype;
+int sloppy;
 
 static struct option longopts[] = {
   { "fake", 0, 0, 'f' },
@@ -190,6 +191,7 @@ void mount_usage()
        printf("\t-w\t\tMount file system read-write\n");
        printf("\t-f\t\tFake mount, don't actually mount\n");
        printf("\t-n\t\tDo not update /etc/mtab\n");
+       printf("\t-s\t\tTolerate sloppy mount options rather than failing.\n");
        printf("\t-h\t\tPrint this help\n");
        printf("\tversion\t\tnfs4 - NFS version 4, nfs - older NFS version supported\n");
        printf("\tnfsoptions\tRefer mount.nfs(8) or nfs(5)\n\n");
@@ -311,7 +313,7 @@ int main(int argc, char *argv[])
                return 0;
        }
 
-       while ((c = getopt_long (argc - 2, argv + 2, "rt:vVwfno:h",
+       while ((c = getopt_long (argc - 2, argv + 2, "rt:vVwfno:hs",
                                longopts, NULL)) != -1) {
                switch (c) {
                case 'r':
@@ -341,6 +343,9 @@ int main(int argc, char *argv[])
                        else
                                mount_opts = xstrdup(optarg);
                        break;
+               case 's':
+                       ++sloppy;
+                       break;
                case 128: /* bind */
                        mounttype = MS_BIND;
                        break;
index 717ad56756cad43f8445b73d4064ad65d2929afb..8aa13c6cf76f7655c158ec44b7762f79e257f868 100644 (file)
@@ -50,6 +50,7 @@
 #endif
 
 extern int verbose;
+extern int sloppy;
 
 char *IDMAPLCK = DEFAULT_DIR "/rpcidmapd";
 #define idmapd_check() do { \
@@ -308,7 +309,7 @@ int nfs4mount(const char *spec, const char *node, int *flags,
                                num_flavour = parse_sec(opteq+1, pseudoflavour);
                                if (!num_flavour)
                                        goto fail;
-                       } else if (!strcmp(opt, "addr")) {
+                       } else if (!strcmp(opt, "addr") || sloppy) {
                                /* ignore */;
                        } else {
                                printf(_("unknown nfs mount parameter: "
@@ -335,7 +336,7 @@ int nfs4mount(const char *spec, const char *node, int *flags,
                                nocto = !val;
                        else if (!strcmp(opt, "ac"))
                                noac = !val;
-                       else {
+                       else if (!sloppy) {
                                printf(_("unknown nfs mount option: "
                                         "%s%s\n"), val ? "" : "no", opt);
                                goto fail;
index 0188caa2a7b8612d6fe5a2a175d7af922ddfd22d..db1f544d672c116ef872aa83a2ff57660d987380 100644 (file)
@@ -104,6 +104,7 @@ typedef union {
 static char errbuf[BUFSIZ];
 static char *erreob = &errbuf[BUFSIZ];
 extern int verbose;
+extern int sloppy;
 
 /* Convert RPC errors into strings */
 int rpc_strerror(int);
@@ -606,13 +607,17 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
                        } else if (!strcmp(opt, "namlen")) {
                                if (nfs_mount_version >= 2)
                                        data->namlen = val;
+                               else if (sloppy)
+                                       continue;
                                else
                                        goto bad_parameter;
 #endif
                        } else if (!strcmp(opt, "addr")) {
                                /* ignore */;
                                continue;
-                       } else
+                       } else if (sloppy)
+                               continue;
+                       else
                                goto bad_parameter;
                        sprintf(cbuf, "%s=%s,", opt, opteq+1);
                } else if (opteq) {
@@ -629,7 +634,9 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
                                        mnt_pmap->pm_prot = IPPROTO_TCP;
                                        data->flags |= NFS_MOUNT_TCP;
 #endif
-                               } else
+                               } else if (sloppy)
+                                       continue;
+                               else
                                        goto bad_parameter;
 #if NFS_MOUNT_VERSION >= 5
                        } else if (!strcmp(opt, "sec")) {
@@ -660,6 +667,8 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
                                        data->pseudoflavor = AUTH_GSS_SPKMI;
                                else if (!strcmp(secflavor, "spkm3p"))
                                        data->pseudoflavor = AUTH_GSS_SPKMP;
+                               else if (sloppy)
+                                       continue;
                                else {
                                        printf(_("Warning: Unrecognized security flavor %s.\n"),
                                                secflavor);
@@ -679,7 +688,9 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
                                        goto bad_parameter;
                                }
                                strncpy(data->context, context, NFS_MAX_CONTEXT_LEN);
-                       } else
+                       } else if (sloppy)
+                               continue;
+                       else
                                goto bad_parameter;
                        sprintf(cbuf, "%s=%s,", opt, opteq+1);
                } else {
@@ -766,6 +777,8 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 #endif
                        } else {
                        bad_option:
+                               if (sloppy)
+                                       continue;
                                printf(_("Unsupported nfs mount option: "
                                         "%s%s\n"), val ? "" : "no", opt);
                                goto out_bad;