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