public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - gfs2_tool: Use FIFREEZE/FITHAW ioctl
@ 2009-05-27 10:22 Steven Whitehouse
  0 siblings, 0 replies; only message in thread
From: Steven Whitehouse @ 2009-05-27 10:22 UTC (permalink / raw)
  To: cluster-cvs-relay

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);
 }
 
 /**


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-27 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-27 10:22 cluster: STABLE3 - gfs2_tool: Use FIFREEZE/FITHAW ioctl Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).