All of lore.kernel.org
 help / color / mirror / Atom feed
From: rpeterso@sourceware.org <rpeterso@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/gfs2 libgfs2/misc.c tool/Makefile tool ...
Date: 25 Oct 2007 14:14:34 -0000	[thread overview]
Message-ID: <20071025141434.17054.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2007-10-25 14:14:33

Modified files:
	gfs2/libgfs2   : misc.c 
	gfs2/tool      : Makefile counters.c df.c gfs2_tool.h layout.c 
	                 misc.c tune.c util.c 

Log message:
	Resolves: bz 345501: GFS2: gfs2 utils uses non-canonicalized names

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/misc.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/Makefile.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/counters.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/df.c.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/gfs2_tool.h.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/layout.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/misc.c.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/tune.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/util.c.diff?cvsroot=cluster&r1=1.5&r2=1.6

--- cluster/gfs2/libgfs2/misc.c	2007/06/26 01:43:17	1.4
+++ cluster/gfs2/libgfs2/misc.c	2007/10/25 14:14:32	1.5
@@ -170,16 +170,18 @@
 check_for_gfs2(struct gfs2_sbd *sdp)
 {
 	FILE *fp = fopen("/proc/mounts", "r");
-	char *name = sdp->path_name;
 	char buffer[PATH_MAX];
 	char fstype[80];
 	int fsdump, fspass, ret;
 	char fspath[PATH_MAX];
 	char fsoptions[PATH_MAX];
+	char *realname;
 
-	if (name[strlen(name) - 1] == '/')
-		name[strlen(name) - 1] = '\0';
-
+	realname = realpath(sdp->path_name, NULL);
+	if (!realname) {
+		perror(sdp->path_name);
+		return;
+	}
 	if (fp == NULL) {
 		perror("open: /proc/mounts");
 		exit(EXIT_FAILURE);
@@ -199,19 +201,21 @@
 			continue;
 
 		/* Check if they specified the device instead of mnt point */
-		if (strcmp(sdp->device_name, name) == 0)
+		if (strcmp(sdp->device_name, realname) == 0)
 			strcpy(sdp->path_name, fspath); /* fix it */
-		else if (strcmp(fspath, name) != 0)
+		else if (strcmp(fspath, realname) != 0)
 			continue;
 
 		fclose(fp);
 		if (strncmp(sdp->device_name, "/dev/loop", 9) == 0)
 			die("Cannot perform this operation on a loopback GFS2 mount.\n");
 
+		free(realname);
 		return;
 	}
+	free(realname);
 	fclose(fp);
-	die("gfs2 Filesystem %s is not mounted.\n", name);
+	die("gfs2 Filesystem %s is not mounted.\n", sdp->path_name);
 }
 
 void 
--- cluster/gfs2/tool/Makefile	2007/08/28 04:35:44	1.13
+++ cluster/gfs2/tool/Makefile	2007/10/25 14:14:33	1.14
@@ -27,7 +27,7 @@
 
 CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += -I${KERNEL_SRC}/fs/gfs2/ -I${KERNEL_SRC}/include/
-CFLAGS += -I../include
+CFLAGS += -I../include -I../libgfs2/
 CFLAGS += -I${incdir}
 
 LDFLAGS += -L../libgfs2 -lgfs2
--- cluster/gfs2/tool/counters.c	2006/05/05 18:06:09	1.3
+++ cluster/gfs2/tool/counters.c	2007/10/25 14:14:33	1.4
@@ -28,6 +28,7 @@
 #include "osi_list.h"
 
 #include "gfs2_tool.h"
+#include "libgfs2.h"
 
 #define SIZE (65536)
 
@@ -132,24 +133,19 @@
 print_counters(int argc, char **argv)
 {
 	unsigned int i = interval;
-	char *path, *fs;
-	int fd;
+	char *fs;
+	struct gfs2_sbd sbd;
 
 	interval = 1;
 
 	if (optind < argc)
-		path = argv[optind++];
+		sbd.path_name = argv[optind++];
 	else
 		die("Usage: gfs2_tool counters <mountpoint>\n");
 
-	fd = open(path, O_RDONLY);
-	if (fd < 0)
-		die("can't open file %s: %s\n", path, strerror(errno));
+	check_for_gfs2(&sbd);
 
-	check_for_gfs2(fd, path);
-	close(fd);
-
-	fs = mp2fsname(path);
+	fs = mp2fsname(sbd.path_name);
 
 	for (;;) {
 		print_line(fs, "glock_count", "locks", 0);
@@ -204,6 +200,4 @@
 			first = FALSE;
 		}
 	}
-
-	close(fd);
 }
--- cluster/gfs2/tool/df.c	2006/05/05 18:06:09	1.7
+++ cluster/gfs2/tool/df.c	2007/10/25 14:14:33	1.8
@@ -29,6 +29,7 @@
 #include <linux/gfs2_ondisk.h>
 
 #include "gfs2_tool.h"
+#include "libgfs2.h"
 
 #define SIZE (65536)
 
@@ -42,7 +43,6 @@
 static void
 do_df_one(char *path)
 {
-	int fd;
 	struct gfs2_ioctl gi;
 	/* char stat_gfs2[SIZE]; */
 	/* unsigned int percentage; */
@@ -53,14 +53,15 @@
 	unsigned int flags;
 	char *fs, *value;
  	int error;
+	struct gfs2_sbd sbd;
 
+	sbd.path_name = path;
+	check_for_gfs2(&sbd);
 
-	fd = open(path, O_RDONLY);
-	if (fd < 0)
+	sbd.device_fd = open(path, O_RDONLY);
+	if (sbd.device_fd < 0)
 		die("can't open %s: %s\n", path, strerror(errno));
 
-	check_for_gfs2(fd, path);
-
 	fs = mp2fsname(path);
 
 	/*
@@ -76,7 +77,7 @@
 		gi.gi_data = (char *)&sb;
 		gi.gi_size = sizeof(struct gfs2_sb);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_super (%d): %s\n",
 			    error, strerror(errno));
@@ -90,7 +91,7 @@
 		gi.gi_data = (char *)&ji;
 		gi.gi_size = sizeof(struct gfs2_dinode);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_hfile_stat for jindex (%d): %s\n",
 			    error, strerror(errno));
@@ -104,13 +105,13 @@
 		gi.gi_data = (char *)&ri;
 		gi.gi_size = sizeof(struct gfs2_dinode);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_hfile_stat for rindex (%d): %s\n",
 			    error, strerror(errno));
 	}
 
-	close(fd);
+	close(sbd.device_fd);
 
 	journals = ji.di_entries - 2;
 
--- cluster/gfs2/tool/gfs2_tool.h	2007/05/10 15:47:45	1.6
+++ cluster/gfs2/tool/gfs2_tool.h	2007/10/25 14:14:33	1.7
@@ -92,7 +92,6 @@
 
 /* From util.c */
 
-void check_for_gfs2(int fd, char *path);
 char *get_list(void);
 char **str2lines(char *str);
 const char *find_debugfs_mount(void);
--- cluster/gfs2/tool/layout.c	2006/05/05 18:06:09	1.3
+++ cluster/gfs2/tool/layout.c	2007/10/25 14:14:33	1.4
@@ -32,6 +32,7 @@
 #include "linux_endian.h"
 
 #include "gfs2_tool.h"
+#include "libgfs2.h"
 
 #define LAYOUT_DATA_QUANTUM (4194304)
 
@@ -765,11 +766,10 @@
 print_layout(int argc, char **argv)
 {
 	world_t w;
-	char *path;
-	int fd;
 	int retry = TRUE;
 	struct gfs2_ioctl gi;
 	int error;
+	struct gfs2_sbd sbd;
 
 	memset(&w, 0, sizeof(world_t));
 	w.buf_size = LAYOUT_DATA_QUANTUM;
@@ -779,17 +779,17 @@
 	if (optind == argc)
 		die("Usage: gfs2_tool layout <filename> [buffersize]\n");
 
-	path = argv[optind++];
+	sbd.path_name = argv[optind++];
 	if (optind < argc ) {
 		w.buf_size = atoi(argv[3]);
 		retry = FALSE;
 	}
 
-	fd = open(path, O_RDONLY);
-	if (fd < 0)
-		die("can't open %s: %s\n", path, strerror(errno));
+	sbd.device_fd = open(sbd.path_name, O_RDONLY);
+	if (sbd.device_fd < 0)
+		die("can't open %s: %s\n", sbd.path_name, strerror(errno));
 
-	check_for_gfs2(fd, path);
+	check_for_gfs2(&sbd);
 
 	{
 		char *argv[] = { "get_super" };
@@ -799,7 +799,7 @@
 		gi.gi_data = (char *)&w.sb;
 		gi.gi_size = sizeof(struct gfs2_sb);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_super (%d): %s\n",
 			    error, strerror(errno));
@@ -825,7 +825,7 @@
 		gi.gi_data = w.buf_data;
 		gi.gi_size = w.buf_size;
 
-		w.buf_count = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		w.buf_count = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (w.buf_count >= 0)
 			break;
 
@@ -855,7 +855,7 @@
 
 	check_for_untouched_buffers(&w);
 
-	close(fd);
+	close(sbd.device_fd);
 }
 #endif /* #if GFS2_TOOL_FEATURE_IMPLEMENTED */
 
--- cluster/gfs2/tool/misc.c	2006/10/26 18:42:25	1.8
+++ cluster/gfs2/tool/misc.c	2007/10/25 14:14:33	1.9
@@ -30,6 +30,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/fs.h>
 
+#include "libgfs2.h"
 #include "gfs2_tool.h"
 
 #if GFS2_TOOL_FEATURE_IMPLEMENTED
@@ -47,6 +48,7 @@
 	struct gfs2_ioctl gi;
 	int fd;
 	int error;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool flush <filenames>\n");
@@ -59,7 +61,8 @@
 		if (fd < 0)
 			die("can't open %s: %s\n", argv[optind], strerror(errno));
 
-		check_for_gfs2(fd, argv[optind]);
+		sbd.path_name = argv[optind];
+		check_for_gfs2(&sbd);
 
 		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
 		if (error)
@@ -107,7 +110,7 @@
 void
 print_lockdump(int argc, char **argv)
 {
-	die("lockdump not implemented\n");
+	die("lockdump not implemented: use debugfs instead.  \ne.g. cat /sys/kernel/debug/gfs2/clustname\:fsname/glocks\n");
 }
 
 /**
@@ -237,32 +240,33 @@
 void
 print_stat(int argc, char **argv)
 {
-	int fd;
 	char *gi_argv[] = { "get_file_stat" };
 	struct gfs2_ioctl gi;
 	struct gfs2_dinode di;
 	int error;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool stat <filename>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
+	sbd.device_fd = open(argv[optind], O_RDONLY);
+	if (sbd.device_fd < 0)
 		die("can't open %s: %s\n", argv[optind], strerror(errno));
 
-	check_for_gfs2(fd, argv[optind]);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sbd);
 
 	gi.gi_argc = 1;
 	gi.gi_argv = gi_argv;
 	gi.gi_data = (char *)&di;
 	gi.gi_size = sizeof(struct gfs2_dinode);
 
-	error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+	error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 	if (error != gi.gi_size)
 		die("error doing get_file_stat (%d): %s\n",
 		    error, strerror(errno));
 
-	close(fd);
+	close(sbd.device_fd);
 
 	gfs2_dinode_print(&di);
 	printf("\n");
@@ -279,32 +283,33 @@
 void
 print_sb(int argc, char **argv)
 {
-	int fd;
 	char *gi_argv[] = { "get_super" };
 	struct gfs2_ioctl gi;
 	struct gfs2_sb sb;
 	int error;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool getsb <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
+	sbd.device_fd = open(argv[optind], O_RDONLY);
+	if (sbd.device_fd < 0)
 		die("can't open %s: %s\n", argv[optind], strerror(errno));
 	
-	check_for_gfs2(fd, argv[optind]);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sbd);
 
 	gi.gi_argc = 1;
 	gi.gi_argv = gi_argv;
 	gi.gi_data = (char *)&sb;
 	gi.gi_size = sizeof(struct gfs2_sb);
 
-	error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+	error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 	if (error != gi.gi_size)
 		die("error doing get_super (%d): %s\n",
 		    error, strerror(errno));
 
-	close(fd);
+	close(sbd.device_fd);
 
 	gfs2_sb_print(&sb);
 }
@@ -321,22 +326,17 @@
 void
 print_args(int argc, char **argv)
 {
-	int fd;
 	char *fs;
 	DIR *d;
 	struct dirent *de;
 	char path[PATH_MAX];
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool getargs <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
-		die("can't open %s: %s\n", argv[optind], strerror(errno));
-	
-	check_for_gfs2(fd, argv[optind]);
-
-	close(fd);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sbd);
 	fs = mp2fsname(argv[optind]);
 
 	memset(path, 0, PATH_MAX);
@@ -369,19 +369,19 @@
 void
 print_jindex(int argc, char **argv)
 {
-	int fd;
 	struct gfs2_ioctl gi;
 	int error;
-
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool jindex <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
+	sbd.device_fd = open(argv[optind], O_RDONLY);
+	if (sbd.device_fd < 0)
 		die("can't open %s: %s\n", argv[optind], strerror(errno));
 
-	check_for_gfs2(fd, argv[optind]);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sdp);
 
 
 	{
@@ -394,7 +394,7 @@
 		gi.gi_data = (char *)&di;
 		gi.gi_size = sizeof(struct gfs2_dinode);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_hfile_stat (%d): %s\n",
 			    error, strerror(errno));
@@ -404,7 +404,7 @@
 	}
 
 
-	close(fd);
+	close(sbd.device_fd);
 }
 
 /**
@@ -417,21 +417,21 @@
 void
 print_rindex(int argc, char **argv)
 {
-	int fd;
 	struct gfs2_ioctl gi;
 	uint64_t offset;
 	unsigned int x;
 	int error;
-
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool rindex <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
+	sbd.device_fd = open(argv[optind], O_RDONLY);
+	if (sbd.device_fd < 0)
 		die("can't open %s: %s\n", argv[optind], strerror(errno));
 
-	check_for_gfs2(fd, argv[optind]);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sdp);
 
 
 	{
@@ -444,7 +444,7 @@
 		gi.gi_data = (char *)&di;
 		gi.gi_size = sizeof(struct gfs2_dinode);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_hfile_stat (%d): %s\n",
 			    error, strerror(errno));
@@ -465,7 +465,7 @@
 		gi.gi_size = sizeof(struct gfs2_rindex);
 		gi.gi_offset = offset;
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (!error)
 			break;
 		if (error != sizeof(struct gfs2_rindex))
@@ -479,7 +479,7 @@
 	}
 
 
-	close(fd);
+	close(sbd.device_fd);
 }
 
 /**
@@ -492,21 +492,21 @@
 void
 print_quota(int argc, char **argv)
 {
-	int fd;
 	struct gfs2_ioctl gi;
 	uint64_t offset;
 	unsigned int x;
 	int error;
-
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool quota <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
+	sbd.device_fd = open(argv[optind], O_RDONLY);
+	if (sbd.device_fd < 0)
 		die("can't open %s: %s\n", argv[optind], strerror(errno));
 
-	check_for_gfs2(fd, argv[optind]);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sdp);
 
 
 	{
@@ -519,7 +519,7 @@
 		gi.gi_data = (char *)&di;
 		gi.gi_size = sizeof(struct gfs2_dinode);
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (error != gi.gi_size)
 			die("error doing get_hfile_stat (%d): %s\n",
 			    error, strerror(errno));
@@ -540,7 +540,7 @@
 		gi.gi_size = sizeof(struct gfs2_quota);
 		gi.gi_offset = offset;
 
-		error = ioctl(fd, GFS2_IOCTL_SUPER, &gi);
+		error = ioctl(sbd.device_fd, GFS2_IOCTL_SUPER, &gi);
 		if (!error)
 			break;
 		if (error != sizeof(struct gfs2_quota))
@@ -556,7 +556,7 @@
 	}
 
 
-	close(fd);
+	close(sbd.device_fd);
 }
 #endif /* #if GFS2_TOOL_FEATURE_IMPLEMENTED */
 
@@ -582,19 +582,14 @@
 void
 do_shrink(int argc, char **argv)
 {
-	int fd;
 	char *fs;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool shrink <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
-		die("can't open %s: %s\n",
-		    argv[optind], strerror(errno));
-
-	check_for_gfs2(fd, argv[optind]);
-	close(fd);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sbd);
 	fs = mp2fsname(argv[optind]);
 	
 	set_sysfs(fs, "shrink", "1");
@@ -611,10 +606,13 @@
 do_withdraw(int argc, char **argv)
 {
 	char *name;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool withdraw <mountpoint>\n");
 
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sbd);
 	name = mp2fsname(argv[optind]);
 
 	set_sysfs(name, "withdraw", "1");
--- cluster/gfs2/tool/tune.c	2006/05/05 18:06:09	1.3
+++ cluster/gfs2/tool/tune.c	2007/10/25 14:14:33	1.4
@@ -29,6 +29,7 @@
 #define __user
 
 #include "gfs2_tool.h"
+#include "libgfs2.h"
 
 #define SIZE (65536)
 
@@ -42,24 +43,19 @@
 void
 get_tune(int argc, char **argv)
 {
-	int fd;
 	char path[PATH_MAX];
 	char *fs;
 	DIR *d;
 	struct dirent *de;
 	double ratio;
 	unsigned int num, den;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool gettune <mountpoint>\n");
 
-	fd = open(argv[optind], O_RDONLY);
-	if (fd < 0)
-		die("can't open file %s: %s\n",
-		    argv[optind], strerror(errno));
-
-	check_for_gfs2(fd, argv[optind]);
-	close(fd);
+	sbd.path_name = argv[optind];
+	check_for_gfs2(&sbd);
 	fs = mp2fsname(argv[optind]);
 	memset(path, 0, PATH_MAX);
 	snprintf(path, PATH_MAX - 1, "%s/%s/tune", SYS_BASE, fs);
@@ -94,15 +90,15 @@
 void
 set_tune(int argc, char **argv)
 {
-	char *mp, *param, *value;
-	int fd;
+	char *param, *value;
 	char tune_base[SIZE] = "tune/";
 	char buf[256];
 	char *fs;
+	struct gfs2_sbd sbd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n");
-	mp = argv[optind++];
+	sbd.path_name = argv[optind++];
 	if (optind == argc)
 		die("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n");
 	param = argv[optind++];
@@ -110,14 +106,8 @@
 		die("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n");
 	value = argv[optind++];
 
-	fd = open(mp, O_RDONLY);
-	if (fd < 0)
-		die("can't open file %s: %s\n",
-		    mp, strerror(errno));
-
-	check_for_gfs2(fd, mp);
-	close(fd);
-	fs = mp2fsname(mp);
+	check_for_gfs2(&sbd);
+	fs = mp2fsname(sbd.path_name);
 
 	if (strcmp(param, "quota_scale") == 0) {
 		float s;
--- cluster/gfs2/tool/util.c	2006/06/15 16:40:48	1.5
+++ cluster/gfs2/tool/util.c	2007/10/25 14:14:33	1.6
@@ -168,34 +168,6 @@
 }
 
 /**
- * check_for_gfs2 - Check to see if a descriptor is a file on a GFS2 filesystem
- * @fd: the file descriptor
- * @path: the path used to open the descriptor
- *
- */
-
-/* 
- * FIXME check_for_gfs2() uses an ioctl that's not supported by gfs2.
- * This function is used as a sanity check before performing certain
- * operations.
- */
-#if 0
-void
-check_for_gfs2(int fd, char *path)
-{
-	unsigned int magic = 0;
-	int error = 0;
-	error = ioctl(fd, GFS2_IOCTL_IDENTIFY, &magic);
-	if (error || magic != GFS2_MAGIC)
-		die("%s is not a GFS2 file/filesystem\n",
-		    path);
-}
-#else
-void check_for_gfs2(int fd, char *path) {}
-#endif /* #if 0 */
-
-
-/**
  * str2lines - parse a string into lines
  * @list: the list
  *
@@ -280,7 +252,11 @@
 	char line[PATH_MAX];
 	static char device[PATH_MAX];
 	char *name = NULL;
+	char *realname;
 
+	realname = realpath(mp, NULL);
+	if (!realname)
+		die("Unable to allocate memory for name resolution.\n");
 	file = fopen("/proc/mounts", "r");
 	if (!file)
 		die("can't open /proc/mounts: %s\n", strerror(errno));
@@ -290,7 +266,7 @@
 
 		if (sscanf(line, "%s %s %s", device, path, type) != 3)
 			continue;
-		if (strcmp(path, mp))
+		if (strcmp(path, realname))
 			continue;
 		if (strcmp(type, "gfs2"))
 			die("%s is not a GFS2 filesystem\n", mp);
@@ -300,6 +276,7 @@
 		break;
 	}
 
+	free(realname);
 	fclose(file);
 
 	return name;



             reply	other threads:[~2007-10-25 14:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25 14:14 rpeterso [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-10-25 14:14 [Cluster-devel] cluster/gfs2 libgfs2/misc.c tool/Makefile tool rpeterso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071025141434.17054.qmail@sourceware.org \
    --to=rpeterso@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.