Skip to contentSkip to conversation

Handle multiple filesystems on a single mountpoint

PATCH New Pierre Carrier 1 participant 2 messages Aug 23, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Handle multiple filesystems on a single mountpoint

Hello,

Here is a patch against gfs1-utils.git

Use-case:
When both a GFS and a GFS2 filesystems are mounted on the same mountpoint,

# umount /example
/sbin/umount.gfs2: /example is not a gfs2 filesystem
/sbin/umount.gfs: /example is not a gfs filesystem
/sbin/umount.gfs2: /example is not a gfs2 filesystem

Best regards,

Signature · 4 lines
Pierre
---
 gfs/gfs_tool/util.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
gfs/gfs_tool/util.c +8 -3
index f467b7e..bc9cf50 100644
@@ -123,7 +123,7 @@ mp2cookie(char *mp, int ioctl_ok)
 	char *list, **lines;
 	FILE *file;
 	char line[256], device[256], dev_id[256];
-	unsigned int x;
+	unsigned int x, non_gfs_found = 0;
 	struct stat st;
 
 	cookie = malloc(256);
@@ -145,8 +145,10 @@ mp2cookie(char *mp, int ioctl_ok)
 			continue;
 		if (strcmp(path, mp))
 			continue;
-		if (strcmp(type, "gfs"))
-			die("%s is not a GFS filesystem\n", mp);
+		if (strcmp(type, "gfs")) {
+			non_gfs_found++;
+			continue;
+		}
 
 		if (stat(device, &st))
 			continue;
@@ -154,6 +156,9 @@ mp2cookie(char *mp, int ioctl_ok)
 		break;
 	}
 
+	if(!dev_id[0] && non_gfs_found)
+		die("Only %u non-GFS filesystems are mounted on %s\n", non_gfs_found, mp);
+
 	fclose(file);
 
 	for (x = 0; *lines[x]; x++) {
Signature · 1 line
1.7.2.1
#1 lore raw

PATCH 1/1 Handle multiple filesystems on a single mountpoint

Hello,

Here is a patch against gfs2-utils.git

Use-case:
When both a GFS and a GFS2 filesystems are mounted on the same mountpoint,

# umount /example
/sbin/umount.gfs2: /example is not a gfs2 filesystem
/sbin/umount.gfs: /example is not a gfs filesystem
/sbin/umount.gfs2: /example is not a gfs2 filesystem

Best regards,

Signature · 4 lines
Pierre
---
 gfs2/mount/util.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
gfs2/mount/util.c +12 -2
index 42cd8f0..06bdd2c 100644
@@ -221,6 +221,7 @@ void read_proc_mounts(struct mount_options *mo)
 	char save_opts[PATH_MAX];
 	char save_device[PATH_MAX];
 	int found = 0;
+	unsigned int unexpected_type_found = 0;
 	struct stat st_mo_dev, st_mounts_dev;
 
 	file = fopen("/proc/mounts", "r");
@@ -244,8 +245,10 @@ void read_proc_mounts(struct mount_options *mo)
 			if (st_mo_dev.st_rdev != st_mounts_dev.st_rdev)
 				continue;
 		}
-		if (strcmp(type, fsname))
-			die("%s is not a %s filesystem\n", mo->dir, fsname);
+		if (strcmp(type, fsname)) {
+			unexpected_type_found++;
+			continue;
+		}
 
 		/* when there is an input dev specified (mount), we should get
 		   only one matching line; when there is no input dev specified
@@ -256,6 +259,13 @@ void read_proc_mounts(struct mount_options *mo)
 		strncpy(save_line, line, PATH_MAX);
 		found = 1;
 	}
+	
+	if(!found) {
+		if(unexpected_type_found)
+		die("Only %u non-%s filesystems found on %s\n",
+		    unexpected_type_found, fsname, mo->dir);
+		die("%s is not a %s filesystem\n", mo->dir, fsname);
+	}
 
 	fclose(file);
 
Signature · 1 line
1.7.2.1