Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 1/3] Fix handling of explicit uuid
       [not found]     ` <1219058258.3184.358.camel@pmac.infradead.org>
@ 2008-08-18 12:17       ` David Woodhouse
       [not found]         ` <1219061850.3184.378.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
       [not found]       ` <1219058258.3184.358.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2008-08-18 12:17 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Artem.Bityutskiy, linux-fsdevel, steved, linux-nfs

Fix a couple of bugs which show up if you try to explicitly set a
16-byte UUID when exporting a file system. First, exportfs cuts the
first two bytes off the UUID and writes something invalid to etab.
Second, mountd writes the _ascii_ form of the UUID to the kernel,
instead of converting it to hex.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 support/nfs/exports.c |    2 +-
 utils/mountd/cache.c  |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index 525e5b1..334c08e 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -595,7 +595,7 @@ bad_option:
 				if (opt[5]!='\0' && *oe == '\0') 
 					ep->e_flags |= NFSEXP_FSID;
 				else if (valid_uuid(opt+5))
-					ep->e_uuid = strdup(opt+7);
+					ep->e_uuid = strdup(opt+5);
 				else {
 					xlog(L_ERROR, "%s: %d: bad fsid \"%s\"\n",
 					     flname, flline, opt);	
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index f555dcc..cd377ce 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -590,8 +590,10 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
  				qword_printhex(f, u, 16);
  			}
  		} else {
+			char u[16];
+			get_uuid(NULL, exp->e_uuid, 16, u);
  			qword_print(f, "uuid");
- 			qword_printhex(f, exp->e_uuid, 16);
+ 			qword_printhex(f, u, 16);
  		}
 #endif
 	}
-- 
1.5.5.1


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] Explicit UUID handling doesn't require blkid; factor out get_uuid_blkdev()
       [not found]       ` <1219058258.3184.358.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
@ 2008-08-18 12:17         ` David Woodhouse
       [not found]           ` <1219061859.3184.380.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
  2008-08-18 12:17         ` [PATCH 3/3] Use fsid from statfs for UUID if blkid can't cope (or not used) David Woodhouse
  2008-08-18 16:00         ` [PATCH 4/3] Stop exportfs warning about needing fsid, when we actually have one David Woodhouse
  2 siblings, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2008-08-18 12:17 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Artem.Bityutskiy, linux-fsdevel, steved, linux-nfs

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 utils/mountd/cache.c |   74 +++++++++++++++++++++++++++-----------------------
 1 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index cd377ce..0136eca 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -14,6 +14,7 @@
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/stat.h>
+#include <sys/vfs.h>
 #include <time.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -165,6 +166,41 @@ void auth_unix_gid(FILE *f)
 }
 
 #if USE_BLKID
+static const char *get_uuid_blkdev(char *path)
+{
+	static blkid_cache cache = NULL;
+	struct stat stb;
+	char *devname;
+	blkid_tag_iterate iter;
+	blkid_dev dev;
+	const char *type;
+	const char *val = NULL;
+
+	if (cache == NULL)
+		blkid_get_cache(&cache, NULL);
+
+	if (stat(path, &stb) != 0)
+		return NULL;
+	devname = blkid_devno_to_devname(stb.st_dev);
+	if (!devname)
+		return NULL;
+	dev = blkid_get_dev(cache, devname, BLKID_DEV_NORMAL);
+	free(devname);
+	if (!dev)
+		return NULL;
+	iter = blkid_tag_iterate_begin(dev);
+	if (!iter)
+		return NULL;
+	while (blkid_tag_next(iter, &type, &val) == 0)
+		if (strcmp(type, "UUID") == 0)
+			break;
+	blkid_tag_iterate_end(iter);
+	return val;
+}
+#else
+#define get_uuid_blkdev(path) (NULL)
+#endif
+
 int get_uuid(char *path, char *uuid, int uuidlen, char *u)
 {
 	/* extract hex digits from uuidstr and compose a uuid
@@ -172,35 +208,12 @@ int get_uuid(char *path, char *uuid, int uuidlen, char *u)
 	 * a smaller uuid.  Then compare with uuid
 	 */
 	int i = 0;
-	const char *val;
+	const char *val = NULL;
+	char fsid_val[17];
 
 	if (path) {
-		static blkid_cache cache = NULL;
-		struct stat stb;
-		char *devname;
-		blkid_tag_iterate iter;
-		blkid_dev dev;
-		const char *type;
-		if (cache == NULL)
-			blkid_get_cache(&cache, NULL);
-
-		if (stat(path, &stb) != 0)
-			return 0;
-		devname = blkid_devno_to_devname(stb.st_dev);
-		if (!devname)
-			return 0;
-		dev = blkid_get_dev(cache, devname, BLKID_DEV_NORMAL);
-		free(devname);
-		if (!dev)
-			return 0;
-		iter = blkid_tag_iterate_begin(dev);
-		if (!iter)
-			return 0;
-		while (blkid_tag_next(iter, &type, &val) == 0)
-			if (strcmp(type, "UUID") == 0)
-				break;
-		blkid_tag_iterate_end(iter);
-		if (!type)
+		val = get_uuid_blkdev(path);
+		if (!val)
 			return 0;
 	} else {
 		val = uuid;
@@ -227,7 +240,6 @@ int get_uuid(char *path, char *uuid, int uuidlen, char *u)
 	}
 	return 1;
 }
-#endif
 
 /* Iterate through /etc/mtab, finding mountpoints
  * at or below a given path
@@ -437,7 +449,6 @@ void nfsd_fh(FILE *f)
 				if (!is_mountpoint(path))
 					continue;
 			check_uuid:
-#if USE_BLKID
 				if (exp->m_export.e_uuid)
 					get_uuid(NULL, exp->m_export.e_uuid,
 						 uuidlen, u);
@@ -448,9 +459,6 @@ void nfsd_fh(FILE *f)
 				if (memcmp(u, fhuuid, uuidlen) != 0)
 					continue;
 				break;
-#else
-				continue;
-#endif
 			}
 			if (use_ipaddr) {
 				if (he == NULL) {
@@ -582,7 +590,6 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
 		qword_printint(f, exp->e_fsid);
 		write_fsloc(f, exp, path);
 		write_secinfo(f, exp);
-#if USE_BLKID
  		if (exp->e_uuid == NULL || different_fs) {
  			char u[16];
  			if (get_uuid(path, NULL, 16, u)) {
@@ -595,7 +602,6 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
  			qword_print(f, "uuid");
  			qword_printhex(f, u, 16);
  		}
-#endif
 	}
 	return qword_eol(f);
 }
-- 
1.5.5.1


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] Use fsid from statfs for UUID if blkid can't cope (or not used)
       [not found]       ` <1219058258.3184.358.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
  2008-08-18 12:17         ` [PATCH 2/3] Explicit UUID handling doesn't require blkid; factor out get_uuid_blkdev() David Woodhouse
@ 2008-08-18 12:17         ` David Woodhouse
       [not found]           ` <1219061860.3184.382.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
  2008-08-18 16:00         ` [PATCH 4/3] Stop exportfs warning about needing fsid, when we actually have one David Woodhouse
  2 siblings, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2008-08-18 12:17 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Artem.Bityutskiy, linux-fsdevel, steved, linux-nfs

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 utils/mountd/cache.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 0136eca..f29b885 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -213,8 +213,17 @@ int get_uuid(char *path, char *uuid, int uuidlen, char *u)
 
 	if (path) {
 		val = get_uuid_blkdev(path);
-		if (!val)
-			return 0;
+		if (!val) {
+			struct statfs64 st;
+
+			if (statfs64(path, &st))
+				return 0;
+			if (!st.f_fsid.__val[0] && !st.f_fsid.__val[1])
+				return 0;
+			snprintf(fsid_val, 17, "%08x%08x",
+				 st.f_fsid.__val[0], st.f_fsid.__val[1]);
+			val = fsid_val;
+		}
 	} else {
 		val = uuid;
 	}
-- 
1.5.5.1


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/3] Stop exportfs warning about needing fsid, when we actually have one
       [not found]       ` <1219058258.3184.358.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
  2008-08-18 12:17         ` [PATCH 2/3] Explicit UUID handling doesn't require blkid; factor out get_uuid_blkdev() David Woodhouse
  2008-08-18 12:17         ` [PATCH 3/3] Use fsid from statfs for UUID if blkid can't cope (or not used) David Woodhouse
@ 2008-08-18 16:00         ` David Woodhouse
  2008-08-28 15:39           ` Steve Dickson
  2 siblings, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2008-08-18 16:00 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Artem.Bityutskiy, linux-fsdevel, steved, linux-nfs

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 utils/exportfs/exportfs.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 18dfe5a..fec2571 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -12,6 +12,7 @@
 #include <config.h>
 #endif
 
+#include <sys/vfs.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -388,6 +389,8 @@ validate_export(nfs_export *exp)
 	 */
 	struct stat stb;
 	char *path = exp->m_export.e_path;
+	struct statfs64 stf;
+	int fs_has_fsid = 0;
 
 	if (stat(path, &stb) < 0) {
 		fprintf(stderr, "exportfs: Warning: %s does not exist\n",
@@ -403,7 +406,12 @@ validate_export(nfs_export *exp)
 	if (!can_test())
 		return;
 
-	if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid) {
+	if (!statfs64(path, &stf) &&
+	    (stf.f_fsid.__val[0] || stf.f_fsid.__val[1]))
+		fs_has_fsid = 1;
+
+	if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid ||
+	    fs_has_fsid) {
 		if ( !test_export(path, 1)) {
 			fprintf(stderr, "exportfs: Warning: %s does not "
 				"support NFS export.\n",
-- 
1.5.5.1



-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] Fix handling of explicit uuid
       [not found]         ` <1219061850.3184.378.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
@ 2008-08-28 15:38           ` Steve Dickson
  0 siblings, 0 replies; 8+ messages in thread
From: Steve Dickson @ 2008-08-28 15:38 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Trond Myklebust, Artem.Bityutskiy, linux-fsdevel, linux-nfs



David Woodhouse wrote:
> Fix a couple of bugs which show up if you try to explicitly set a
> 16-byte UUID when exporting a file system. First, exportfs cuts the
> first two bytes off the UUID and writes something invalid to etab.
> Second, mountd writes the _ascii_ form of the UUID to the kernel,
> instead of converting it to hex.
> 
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Committed...

steved

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] Explicit UUID handling doesn't require blkid; factor out get_uuid_blkdev()
       [not found]           ` <1219061859.3184.380.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
@ 2008-08-28 15:38             ` Steve Dickson
  0 siblings, 0 replies; 8+ messages in thread
From: Steve Dickson @ 2008-08-28 15:38 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Trond Myklebust, Artem.Bityutskiy, linux-fsdevel, linux-nfs



David Woodhouse wrote:
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Committed...

steved.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] Use fsid from statfs for UUID if blkid can't cope (or not used)
       [not found]           ` <1219061860.3184.382.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
@ 2008-08-28 15:39             ` Steve Dickson
  0 siblings, 0 replies; 8+ messages in thread
From: Steve Dickson @ 2008-08-28 15:39 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Trond Myklebust, Artem.Bityutskiy, linux-fsdevel, linux-nfs



David Woodhouse wrote:
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Committed...

steved.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/3] Stop exportfs warning about needing fsid, when we actually have one
  2008-08-18 16:00         ` [PATCH 4/3] Stop exportfs warning about needing fsid, when we actually have one David Woodhouse
@ 2008-08-28 15:39           ` Steve Dickson
  0 siblings, 0 replies; 8+ messages in thread
From: Steve Dickson @ 2008-08-28 15:39 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Trond Myklebust, Artem.Bityutskiy, linux-fsdevel, linux-nfs



David Woodhouse wrote:
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Committed...

steved.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-08-28 15:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <48A5449F.7050205@nokia.com>
     [not found] ` <1218808776.3184.89.camel@pmac.infradead.org>
     [not found]   ` <1218809892.7037.3.camel@localhost>
     [not found]     ` <1219058258.3184.358.camel@pmac.infradead.org>
2008-08-18 12:17       ` [PATCH 1/3] Fix handling of explicit uuid David Woodhouse
     [not found]         ` <1219061850.3184.378.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
2008-08-28 15:38           ` Steve Dickson
     [not found]       ` <1219058258.3184.358.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
2008-08-18 12:17         ` [PATCH 2/3] Explicit UUID handling doesn't require blkid; factor out get_uuid_blkdev() David Woodhouse
     [not found]           ` <1219061859.3184.380.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
2008-08-28 15:38             ` Steve Dickson
2008-08-18 12:17         ` [PATCH 3/3] Use fsid from statfs for UUID if blkid can't cope (or not used) David Woodhouse
     [not found]           ` <1219061860.3184.382.camel-ZP4jZrcIevRpWr+L1FloEB2eb7JE58TQ@public.gmane.org>
2008-08-28 15:39             ` Steve Dickson
2008-08-18 16:00         ` [PATCH 4/3] Stop exportfs warning about needing fsid, when we actually have one David Woodhouse
2008-08-28 15:39           ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox