This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE3 - gfs2_tool: Use FIFREEZE/FITHAW ioctl


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=873360edd9ae4417fa11379928ecf0f54216cb42
Commit:        873360edd9ae4417fa11379928ecf0f54216cb42
Parent:        8ff7eeb48e16833685a9b2232cd7f4a9921cad83
Author:        Steven Whitehouse <swhiteho@redhat.com>
AuthorDate:    Fri May 22 12:27:42 2009 +0100
Committer:     Steven Whitehouse <swhiteho@redhat.com>
CommitterDate: Wed May 27 10:03:47 2009 +0100

gfs2_tool: Use FIFREEZE/FITHAW ioctl

Updates gfs2_tool to use the generic ioctl rather than
the GFS2 specific interface. Eventually that interface
will be removed, and to the best of my knowledge, this
tool is the only userland package using it.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 gfs2/tool/misc.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c
index df422bd..649c354 100644
--- a/gfs2/tool/misc.c
+++ b/gfs2/tool/misc.c
@@ -23,6 +23,11 @@
 #include "gfs2_tool.h"
 #include "iflags.h"
 
+#ifndef FIFREZE
+#define FIFREEZE        _IOWR('X', 119, int)    /* Freeze */
+#define FITHAW          _IOWR('X', 120, int)    /* Thaw */
+#endif
+
 #define SYS_BASE "/sys/fs/gfs2" /* FIXME: Look in /proc/mounts to find this */
 
 /**
@@ -32,37 +37,35 @@
  *
  */
 
-void
-do_freeze(int argc, char **argv)
+void do_freeze(int argc, char **argv)
 {
 	char *command = argv[optind - 1];
-	char *name;
+	int fd;
 
 	if (optind == argc)
 		die("Usage: gfs2_tool %s <mountpoint>\n", command);
 
-	name = mp2fsname2(argv[optind]);
-	if (!name) {
+	fd = open(argv[optind], O_NOCTTY|O_RDONLY);
+	if (fd < 0) {
 		fprintf(stderr, _("Couldn't find a GFS2 filesystem mounted at %s\n"),
 				argv[optind]);
 		exit(-1);
 	}
 
 	if (strcmp(command, "freeze") == 0) {
-		if (set_sysfs(name, "freeze", "1")) {
-			fprintf(stderr, _("Error writing to sysfs freeze file: %s\n"),
+		if (ioctl(fd, FIFREEZE, 0)) {
+			fprintf(stderr, _("Error freezing fs: %s\n"),
 					strerror(errno));
 			exit(-1);
 		}
 	} else if (strcmp(command, "unfreeze") == 0) {
-		if (set_sysfs(name, "freeze", "0")) {
-			fprintf(stderr, _("Error writing to sysfs freeze file: %s\n"),
+		if (ioctl(fd, FITHAW, 0)) {
+			fprintf(stderr, _("Error thawing fs: %s\n"),
 					strerror(errno));
 			exit(-1);
 		}
 	}
-
-	sync();
+	close(fd);
 }
 
 /**


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]