[Cluster-devel] cluster/gfs2/mount mount.gfs2.c umount.gfs2.c
teigland at sourceware.org
teigland at sourceware.org
Wed Jun 13 18:13:33 UTC 2007
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-06-13 18:13:33
Modified files:
gfs2/mount : mount.gfs2.c umount.gfs2.c
Log message:
Block SIGINT (^C) around the three steps of mount:
joining the mountgroup, doing kernel mount, adding mtab entry.
And the same for doing the opposite in unmount.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/mount.gfs2.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.20.2.3&r2=1.20.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/umount.gfs2.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.12.2.1&r2=1.12.2.2
--- cluster/gfs2/mount/mount.gfs2.c 2007/05/14 19:08:43 1.20.2.3
+++ cluster/gfs2/mount/mount.gfs2.c 2007/06/13 18:13:33 1.20.2.4
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
@@ -11,6 +11,7 @@
char *prog_name;
char *fsname;
int verbose;
+static sigset_t old_sigset;
static void print_version(void)
{
@@ -24,14 +25,18 @@
printf("This program is called by mount(8), it should not be used directly.\n");
}
-static void block_signals(int how)
+static void block_sigint(void)
{
- sigset_t sigs;
- sigfillset(&sigs);
- sigdelset(&sigs, SIGTRAP);
- sigdelset(&sigs, SIGSEGV);
- sigdelset(&sigs, SIGINT);
- sigprocmask(how, &sigs, (sigset_t *) 0);
+ sigset_t new;
+
+ sigemptyset(&new);
+ sigaddset(&new, SIGINT);
+ sigprocmask(SIG_BLOCK, &new, &old_sigset);
+}
+
+static void unblock_sigint(void)
+{
+ sigprocmask(SIG_SETMASK, &old_sigset, NULL);
}
static void read_options(int argc, char **argv, struct mount_options *mo)
@@ -203,12 +208,15 @@
proto = select_lockproto(&mo, &sb);
+ /* there are three parts to the mount and we want all three or none
+ to happen: joining the mountgroup, doing the kernel mount, and
+ adding the mtab entry */
+ block_sigint();
+
rv = mount_lockproto(proto, &mo, &sb);
if (rv < 0)
die("error mounting lockproto %s\n", proto);
- block_signals(SIG_BLOCK);
-
rv = mount(mo.dev, mo.dir, fsname, mo.flags, mo.extra_plus);
if (rv) {
log_debug("mount(2) failed error %d errno %d", rv, errno);
@@ -217,7 +225,6 @@
if (!(mo.flags & MS_REMOUNT))
umount_lockproto(proto, &mo, &sb, errno);
- block_signals(SIG_UNBLOCK);
if (errno == EBUSY)
die("%s already mounted or %s busy\n", mo.dev, mo.dir);
die("error %d mounting %s on %s\n", errno, mo.dev, mo.dir);
@@ -225,11 +232,11 @@
log_debug("mount(2) ok");
mount_result_lockproto(proto, &mo, &sb, 0);
- block_signals(SIG_UNBLOCK);
-
if (!(mo.flags & MS_REMOUNT))
add_mtab_entry(&mo);
+ unblock_sigint();
+
return rv ? 1 : 0;
}
--- cluster/gfs2/mount/umount.gfs2.c 2006/12/01 22:50:58 1.12.2.1
+++ cluster/gfs2/mount/umount.gfs2.c 2007/06/13 18:13:33 1.12.2.2
@@ -12,6 +12,7 @@
char *fsname;
char *expert;
int verbose;
+static sigset_t old_sigset;
static void print_version(void)
{
@@ -28,6 +29,20 @@
}
+static void block_sigint(void)
+{
+ sigset_t new;
+
+ sigemptyset(&new);
+ sigaddset(&new, SIGINT);
+ sigprocmask(SIG_BLOCK, &new, &old_sigset);
+}
+
+static void unblock_sigint(void)
+{
+ sigprocmask(SIG_SETMASK, &old_sigset, NULL);
+}
+
static void read_options(int argc, char **argv, struct mount_options *mo)
{
int cont = 1;
@@ -129,6 +144,8 @@
get_sb(mo.dev, &sb);
parse_opts(&mo);
+ block_sigint();
+
rv = umount(mo.dir);
if (rv) {
if (errno == EBUSY)
@@ -141,6 +158,8 @@
del_mtab_entry(&mo);
+ unblock_sigint();
+
return 0;
}
More information about the Cluster-devel
mailing list