All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/gfs2/mount mount.gfs2.c umount.gfs2.c
Date: 13 Jun 2007 18:13:33 -0000	[thread overview]
Message-ID: <20070613181333.20553.qmail@sourceware.org> (raw)

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;
 }
 



             reply	other threads:[~2007-06-13 18:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-13 18:13 teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-06-13 18:12 [Cluster-devel] cluster/gfs2/mount mount.gfs2.c umount.gfs2.c teigland
2006-07-28 13:58 rpeterso
2006-07-25 13:58 teigland

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=20070613181333.20553.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.