summaryrefslogtreecommitdiffstats
path: root/support/nfs/exports.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2007-02-12 12:25:03 +1100
committerNeil Brown <neilb@suse.de>2007-02-12 12:25:03 +1100
commite91ff0175602cc56f223f1d92de6511099fa40d1 (patch)
tree7d98e93a037f2986572659fa8d2ea2287317cd83 /support/nfs/exports.c
parentf981e46adaab5da3d105b5adf735e9ce9c19a1d5 (diff)
downloadnfs-utils-e91ff0175602cc56f223f1d92de6511099fa40d1.tar.gz
nfs-utils-e91ff0175602cc56f223f1d92de6511099fa40d1.tar.xz
nfs-utils-e91ff0175602cc56f223f1d92de6511099fa40d1.zip
Use UUIDs to identify filesystems if kernel supports it.
This introduces a new dependancy on libblkid. If a filesystem being exported has a UUID that libblkid can extract, then that is passed to the kernel for use in identifying the filesystem in filehandles. This means that 'fsid=' is no longer needed to work around the problem of device numbers changing. fsid= is still needed for fielsystems that have no device, and can now be given 16byute uuid instead of just a 32bit one.
Diffstat (limited to 'support/nfs/exports.c')
-rw-r--r--support/nfs/exports.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index 9b010dc..0994ea2 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -220,6 +220,8 @@ putexportent(struct exportent *ep)
if (ep->e_flags & NFSEXP_FSID) {
fprintf(fp, "fsid=%d,", ep->e_fsid);
}
+ if (ep->e_uuid)
+ fprintf(fp, "fsid=%s,", ep->e_uuid);
if (ep->e_mountpoint)
fprintf(fp, "mountpoint%s%s,",
ep->e_mountpoint[0]?"=":"", ep->e_mountpoint);
@@ -302,6 +304,7 @@ mkexportent(char *hname, char *path, char *options)
ee.e_mountpoint = NULL;
ee.e_nsquids = 0;
ee.e_nsqgids = 0;
+ ee.e_uuid = NULL;
if (strlen(hname) >= sizeof(ee.e_hostname)) {
xlog(L_WARNING, "client name %s too long", hname);
@@ -330,6 +333,17 @@ updateexportent(struct exportent *eep, char *options)
return 1;
}
+
+static int valid_uuid(char *uuid)
+{
+ /* must have 32 hex digits */
+ int cnt;
+ for (cnt = 0 ; *uuid; uuid++)
+ if (isxdigit(*uuid))
+ cnt++;
+ return cnt == 32;
+}
+
/*
* Parse option string pointed to by cp and set mount options accordingly.
*/
@@ -445,13 +459,21 @@ bad_option:
}
} 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);
- goto bad_option;
+ if (strcmp(opt+5, "root") == 0) {
+ ep->e_fsid = 0;
+ ep->e_flags |= NFSEXP_FSID;
+ } else {
+ ep->e_fsid = strtoul(opt+5, &oe, 0);
+ if (opt[5]!='\0' && *oe == '\0')
+ ep->e_flags |= NFSEXP_FSID;
+ else if (valid_uuid(opt+5))
+ ep->e_uuid = strdup(opt+7);
+ else {
+ xlog(L_ERROR, "%s: %d: bad fsid \"%s\"\n",
+ flname, flline, opt);
+ goto bad_option;
+ }
}
- ep->e_flags |= NFSEXP_FSID;
} else if (strcmp(opt, "mountpoint")==0 ||
strcmp(opt, "mp") == 0 ||
strncmp(opt, "mountpoint=", 11)==0 ||