Skip to contentSkip to conversation

cluster/gfs2/tool gfs2_tool.h misc.c util.c

Cluster-devel [email protected] 1 participant 1 message Nov 7, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: rpeterso at sourceware.org 2007-11-07 14:59:28

Modified files:
gfs2/tool : gfs2_tool.h misc.c util.c

Log message:
Resolves: bz 352581: GFS2: implement gfs2_tool lockdump

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/gfs2_tool.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.3&r2=1.5.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/misc.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8.2.3&r2=1.8.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/util.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.2&r2=1.5.2.3

gfs2/tool/gfs2_tool.h +1 -1
@@ -95,7 +95,7 @@
 
 char *get_list(void);
 char **str2lines(char *str);
-const char *find_debugfs_mount(void);
+char *find_debugfs_mount(void);
 char *mp2fsname(char *mp);
 char *name2value(char *str, char *name);
 uint32_t name2u32(char *str, char *name);
gfs2/tool/misc.c +62 -1

75 lines not on this page · raw message

gfs2/tool/util.c +30 -0
@@ -283,6 +283,36 @@
 	return name;
 }
 
+char *
+find_debugfs_mount(void)
+{
+	FILE *file;
+	char line[PATH_MAX];
+	char device[PATH_MAX], type[PATH_MAX];
+	char *path;
+
+	file = fopen("/proc/mounts", "rt");
+	if (!file)
+		die("can't open /proc/mounts: %s\n", strerror(errno));
+
+	path = malloc(PATH_MAX);
+	if (!path)
+		die("Can't allocate memory for debugfs.\n");
+	while (fgets(line, PATH_MAX, file)) {
+
+		if (sscanf(line, "%s %s %s", device, path, type) != 3)
+			continue;
+		if (!strcmp(type, "debugfs")) {
+			fclose(file);
+			return path;
+		}
+	}
+
+	free(path);
+	fclose(file);
+	return NULL;
+}
+
 /* The fsname can be substituted for the mountpoint on the command line.
    This is necessary when we can't resolve a devname from /proc/mounts
    to a fsname. */