public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE3 - gfs2_tool: Use FIFREEZE/FITHAW ioctl
Date: Wed, 27 May 2009 10:22:00 -0000	[thread overview]
Message-ID: <20090527101941.1248E120368@lists.fedorahosted.org> (raw)

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


                 reply	other threads:[~2009-05-27 10:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090527101941.1248E120368@lists.fedorahosted.org \
    --to=swhiteho@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /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 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).