From mboxrd@z Thu Jan 1 00:00:00 1970 From: teigland@sourceware.org Date: 13 Jun 2007 18:12:36 -0000 Subject: [Cluster-devel] cluster/gfs2/mount mount.gfs2.c umount.gfs2.c Message-ID: <20070613181236.19951.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: teigland at sourceware.org 2007-06-13 18:12:36 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&r1=1.23&r2=1.24 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/umount.gfs2.c.diff?cvsroot=cluster&r1=1.13&r2=1.14 --- cluster/gfs2/mount/mount.gfs2.c 2007/05/14 19:01:01 1.23 +++ cluster/gfs2/mount/mount.gfs2.c 2007/06/13 18:12:36 1.24 @@ -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:05 1.13 +++ cluster/gfs2/mount/umount.gfs2.c 2007/06/13 18:12:36 1.14 @@ -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; }