From mboxrd@z Thu Jan 1 00:00:00 1970 From: rohara@sourceware.org Date: 27 Jul 2006 19:26:25 -0000 Subject: [Cluster-devel] cluster/gfs/scripts gfs_safe.pl Message-ID: <20060727192625.11257.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: rohara at sourceware.org 2006-07-27 19:26:25 Added files: gfs/scripts : gfs_safe.pl Log message: Early version of a script to help users determine if a logical volume might be in use by another node. Useful to avoid doing a mkfs or fsck on a mounted filesystem. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/scripts/gfs_safe.pl.diff?cvsroot=cluster&r1=NONE&r2=1.1 /cvs/cluster/cluster/gfs/scripts/gfs_safe.pl,v --> standard output revision 1.1 --- cluster/gfs/scripts/gfs_safe.pl +++ - 2006-07-27 19:26:25.208429000 +0000 @@ -0,0 +1,84 @@ +#!/usr/bin/perl -w + +use strict; + +use vars qw($opt_e $opt_t $opt_v); + +use Getopt::Std; +use IPC::Open3; + +if ($#ARGV < 0) { + print "$0: too few arguments.\n"; + exit; +} + +getopts('e:tv'); + +my ($in, $out, $err, $cmd, $pid, $vol); + +$vol = $ARGV[$#ARGV]; + +$cmd = "lvchange -a n $vol"; +$pid = open3($in, $out, $err, $cmd); + +waitpid($pid, 0); + +if ($?>>8) +{ + while (<$out>) + { + print "$_\n"; + } + exit($?>>8); +} +else +{ + print "* Volume '$vol' is available for maintenance.\n"; + + if ($opt_t) + { + exit; + } + + if ($opt_e) + { + + $cmd = "lvchange -a ey $vol"; + $pid = open3($in, $out, $err, $cmd); + + waitpid($pid, 0); + + if ($?>>8) + { + while (<$out>) + { + print "$_\n"; + } + exit($?>>8); + } + + $cmd = "$opt_e $vol"; + print "$cmd\n"; + $pid = open3($in, $out, $err, $cmd); + + while (<$out>) + { + print "$_"; + } + + waitpid($pid, 0); + + $cmd = "lvchange -a en $vol"; + $pid = open3($in, $out, $err, $cmd); + + if ($?>>8) + { + while (<$out>) + { + print "$_\n"; + } + exit($?>>8); + } + } + exit(0); +}