]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
*** empty log message ***
authorneilbrown <neilbrown>
Thu, 28 Feb 2002 01:37:18 +0000 (01:37 +0000)
committerneilbrown <neilbrown>
Thu, 28 Feb 2002 01:37:18 +0000 (01:37 +0000)
support/export/nfsctl.c
support/include/nfs/export.h
support/include/nfslib.h
support/nfs/exports.c
utils/exportfs/exportfs.c

index 50e2c7953a9db18906c0caf80df382ca323dc623..5f5acccb96ea340ae697eb980ac1ebae406a3630 100644 (file)
@@ -17,7 +17,7 @@
 #include "exportfs.h"
 #include "xio.h"
 
-static int     expsetup(struct nfsctl_export *exparg, nfs_export *exp);
+static int     expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport);
 static int     cltsetup(struct nfsctl_client *cltarg, nfs_client *clp);
 
 int
@@ -34,7 +34,7 @@ export_export(nfs_export *exp)
                        return 0;
                clp->m_exported = 1;
        }
-       if (!expsetup(&exparg, exp))
+       if (!expsetup(&exparg, exp, 0))
                return 0;
        if (nfsexport(&exparg) < 0)
                return 0;
@@ -47,7 +47,7 @@ export_unexport(nfs_export *exp)
 {
        struct nfsctl_export    exparg;
 
-       if (!expsetup(&exparg, exp) || nfsunexport(&exparg) < 0)
+       if (!expsetup(&exparg, exp, 1) || nfsunexport(&exparg) < 0)
                return 0;
        exp->m_exported = 0;
        return 1;
@@ -82,7 +82,7 @@ cltsetup(struct nfsctl_client *cltarg, nfs_client *clp)
 }
 
 static int
-expsetup(struct nfsctl_export *exparg, nfs_export *exp)
+expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport)
 {
        nfs_client              *clp = exp->m_client;
        struct stat             stb;
@@ -103,7 +103,8 @@ expsetup(struct nfsctl_export *exparg, nfs_export *exp)
                sizeof (exparg->ex_client) - 1);
        str_tolower(exparg->ex_client);
        exparg->ex_flags    = exp->m_export.e_flags;
-       exparg->ex_dev      = stb.st_dev;
+       exparg->ex_dev      = (!unexport && (exp->m_export.e_flags & NFSEXP_FSID)) ?
+                               exp->m_export.e_fsid : stb.st_dev;
        exparg->ex_ino      = stb.st_ino;
        exparg->ex_anon_uid = exp->m_export.e_anonuid;
        exparg->ex_anon_gid = exp->m_export.e_anongid;
index 57b0371f1566a09112e8aaaf837bed4114a2214a..344ece550f6ba7a425cc5868cb3253a6701f3d37 100644 (file)
@@ -23,6 +23,7 @@
 #define NFSEXP_CROSSMNT                0x0200
 #define NFSEXP_NOSUBTREECHECK  0x0400
 #define NFSEXP_NOAUTHNLM       0x0800
-#define NFSEXP_ALLFLAGS                0x0FFF
+#define NFSEXP_FSID            0x2000
+#define NFSEXP_ALLFLAGS                0x3FFF
 
 #endif /* _NSF_EXPORT_H */
index 92eb900e186a11d2c707c54e76263caa41ad3cdb..57c703ca9565af521df5bfd128304e4ee14379db 100644 (file)
@@ -72,6 +72,7 @@ struct exportent {
        int             e_nsquids;
        int *           e_sqgids;
        int             e_nsqgids;
+       int             e_fsid;
 };
 
 struct rmtabent {
index 0dce25ff9291dd28d0c4b608c50fe1cc289f9d62..ce49edc2e4f641dc3a1d4ac80c1a94a340810b45 100644 (file)
@@ -176,7 +176,9 @@ putexportent(struct exportent *ep)
                "no_" : "");
        fprintf(fp, "%ssecure_locks,", (ep->e_flags & NFSEXP_NOAUTHNLM)?
                "in" : "");
-
+       if (ep->e_flags & NFSEXP_FSID) {
+               fprintf(fp, "fsid=%d,", ep->e_fsid);
+       }
        fprintf(fp, "mapping=");
        switch (ep->e_maptype) {
        case CLE_MAP_IDENT:
@@ -287,6 +289,8 @@ static int
 parseopts(char *cp, struct exportent *ep)
 {
        int     had_sync_opt = 0;
+       char    *flname = efname?efname:"command line";
+       int     flline = efp?efp->x_line:0;
 
        squids = ep->e_squids; nsquids = ep->e_nsquids;
        sqgids = ep->e_sqgids; nsqgids = ep->e_nsqgids;
@@ -360,11 +364,25 @@ parseopts(char *cp, struct exportent *ep)
                        ep->e_maptype = CLE_MAP_IDENT;
                else if (strcmp(opt, "map_daemon") == 0)        /* old style */
                        ep->e_maptype = CLE_MAP_UGIDD;
-               else if (strncmp(opt, "anonuid=", 8) == 0)
-                       ep->e_anonuid = atoi(opt+8);
-               else if (strncmp(opt, "anongid=", 8) == 0)
-                       ep->e_anongid = atoi(opt+8);
-               else if (strncmp(opt, "squash_uids=", 12) == 0) {
+               else if (strncmp(opt, "anonuid=", 8) == 0) {
+                       char *oe;
+                       ep->e_anonuid = strtol(opt+8, &oe, 10);
+                       if (opt[8]=='\0' || *oe != '\0') {
+                               xlog(L_ERROR, "%s: %d: bad anonuid \"%s\"\n",
+                                    flname, flline, opt);      
+                               free(opt);
+                               return -1;
+                       }
+               } else if (strncmp(opt, "anongid=", 8) == 0) {
+                       char *oe;
+                       ep->e_anongid = strtol(opt+8, &oe, 10);
+                       if (opt[8]=='\0' || *oe != '\0') {
+                               xlog(L_ERROR, "%s: %d: bad anongid \"%s\"\n",
+                                    flname, flline, opt);      
+                               free(opt);
+                               return -1;
+                       }
+               } else if (strncmp(opt, "squash_uids=", 12) == 0) {
                        if (parsesquash(opt+12, &squids, &nsquids, &cp) < 0) {
                                free(opt);
                                return -1;
@@ -374,9 +392,19 @@ parseopts(char *cp, struct exportent *ep)
                                free(opt);
                                return -1;
                        }
+               } else if (strncmp(opt, "fsid=", 5) == 0) {
+                       char *oe;
+                       ep->e_fsid = strtoul(opt+5, &oe, 0);
+                       if (opt[5]=='\0' || *oe != '\0') {
+                               xlog(L_ERROR, "%s: %d: bad fsid \"%s\"\n",
+                                    flname, flline, opt);      
+                               free(opt);
+                               return -1;
+                       }
+                       ep->e_flags |= NFSEXP_FSID;
                } else {
                        xlog(L_ERROR, "%s:%d: unknown keyword \"%s\"\n",
-                                       efname, efp->x_line, opt);
+                                       flname, flline, opt);
                        ep->e_flags |= NFSEXP_ALLSQUASH | NFSEXP_READONLY;
                        free(opt);
                        return -1;
@@ -501,7 +529,7 @@ getexport(char *exp, int len)
        xskip(efp, " \t");
        if ((ok = xgettok(efp, 0, exp, len)) < 0)
                xlog(L_ERROR, "%s:%d: syntax error",
-                       efname, efp->x_line);
+                       efname?"command line":efname, efp->x_line);
        return ok;
 }
 
@@ -509,6 +537,6 @@ static void
 syntaxerr(char *msg)
 {
        xlog(L_ERROR, "%s:%d: syntax error: %s",
-                       efname, efp->x_line, msg);
+                       efname, efp?efp->x_line:0, msg);
 }
 
index 8bd0b44467d6ccf69066055a375a83387dc2d150..41f475036f6586326ee549e57b50b8d0bcfedbc6 100644 (file)
@@ -345,6 +345,8 @@ dump(int verbose)
                                c = dumpopt(c, "no_subtree_check");
                        if (ep->e_flags & NFSEXP_NOAUTHNLM)
                                c = dumpopt(c, "insecure_locks");
+                       if (ep->e_flags & NFSEXP_FSID)
+                               c = dumpopt(c, "fsid=%d", ep->e_fsid);
                        if (ep->e_maptype == CLE_MAP_UGIDD)
                                c = dumpopt(c, "mapping=ugidd");
                        else if (ep->e_maptype == CLE_MAP_FILE)