From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23524 invoked by alias); 22 May 2009 12:36:55 -0000 Received: (qmail 23518 invoked by alias); 22 May 2009 12:36:55 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_46,SPF_HELO_PASS X-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_46,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: gfs2-utils: master - gfs2_tool: Use FIFREEZE/FITHAW ioctl To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: gfs2-utils.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 938529b7cd58a007eadbefea716ecbdee5218050 X-Git-Newrev: 39f775e9824fefdedbf9020abf86b4399537e563 From: Steven Whitehouse Message-Id: <20090522123627.6E13E1201ED@lists.fedorahosted.org> Date: Fri, 22 May 2009 12:36:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00382.txt.bz2 Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=39f775e9824fefdedbf9020abf86b4399537e563 Commit: 39f775e9824fefdedbf9020abf86b4399537e563 Parent: 938529b7cd58a007eadbefea716ecbdee5218050 Author: Steven Whitehouse AuthorDate: Fri May 22 12:27:42 2009 +0100 Committer: Steven Whitehouse CommitterDate: Fri May 22 12:27:42 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 --- 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 \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); } /**