• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl -w
2#
3#   Copyright (c) International Business Machines  Corp., 2000
4#
5#   This program is free software;  you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation; either version 2 of the License, or
8#   (at your option) any later version.
9#
10#   This program is distributed in the hope that it will be useful,
11#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13#   the GNU General Public License for more details.
14#
15#   You should have received a copy of the GNU General Public License
16#   along with this program;  if not, write to the Free Software
17#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#
19
20#
21#  FILE(s)     : partbeat
22#  DESCRIPTION : Quick test to test storage management functions like mount and fsck.
23#                More can be added later without much trouble.  Command line takes the
24#                partition device name (ex: /dev/hda1), an integer for how many iterations
25#                of the test you would like to run and the filesystem type to use (jfs or ext2 for now).
26#  AUTHOR      : Jeff Martin (martinjn@us.ibm.com)
27#  HISTORY     :
28#
29
30$target=$ARGV[0];
31$iterations=$ARGV[1];
32$fstype=$ARGV[2];
33
34print "mkfs:";
35if ($fstype =~ /jfs\b/i) {
36    $tmp = `mkfs.jfs -f $target`;
37    }
38elsif ($fstype =~ /ext2\b/i) {
39    $tmp=`mkfs $target`;
40    }
41elsif ($fstype =~ /ext3\b/i) {
42    $tmp=`mkfs -t ext3 $target`;
43    }
44elsif ($fstype =~ /reiserfs\b/i) {
45    $tmp=`mkreiserfs --format 3.6 -f $target`;
46    }
47else {
48    $tmp=`mkfs $target`;
49    }
50print $tmp;
51
52print "fsck:";
53$tmp=`fsck -t $fstype -a $target`;
54print $tmp;
55
56($junk,$junk,$device)=split(/\//,$target);
57
58`mkdir $device`;
59
60for ($i=1;$i<=$iterations;$i++) {
61    print "mount:";
62    $tmp=`mount -t $fstype $target $device`;
63    print ($tmp."\n");
64
65    `touch $device/indicator$i`;
66
67    print "umount:";
68    $tmp=`umount $target`;
69    print ($tmp."\n");
70    }
71
72print "fsck:";
73$tmp=`fsck -t $fstype -a $target`;
74print $tmp;
75
76`mount -t $fstype $target $device`;
77`rm -f $device/indicator*`;
78