Don't run xfsdb if we're not root.

This commit is contained in:
Andrew Gildfind
2001-02-01 05:05:22 +00:00
parent 11c790e72d
commit 86260e65c5
+18 -15
View File
@@ -73,7 +73,7 @@ use File::Basename;
chomp($os = `uname`); chomp($os = `uname`);
# #
# fsinfo: get filesystem info put it into the global namespace, assigns: # fsinfo: get filesystem info put it into the global namespace, initialises:
# $dev, $type, $blocks, $used, $avail, $cap, $mnt, $mnt_options # $dev, $type, $blocks, $used, $avail, $cap, $mnt, $mnt_options
# $fsblocks, $fsblocksize, $agblocks, $agcount, $imax_pct, $logblocks # $fsblocks, $fsblocksize, $agblocks, $agcount, $imax_pct, $logblocks
# $logstart, $internal # $logstart, $internal
@@ -101,20 +101,22 @@ sub fsinfo {
@mtab = split(/ +/); @mtab = split(/ +/);
$mnt_options = $mtab[3]; $mnt_options = $mtab[3];
# xfs_db: read only, use the default superblock, print everything # if we're running as root run xfs_db on the filesystem
die("Error: $progname: can't read device: \"$dev\"\n") if (! -r $dev); if ($> == 0) {
$_=`xfs_db -r -c sb -c p $dev`; # xfs_db: read only, use the default superblock, print everything
# multiline matching ^$ refers to individual lines... die("Error: $progname: can't read device: \"$dev\"\n") if (! -r $dev);
/^dblocks = (\d+)$/m; $fsblocks=$1; $_=`xfs_db -r -c sb -c p $dev`;
/^blocksize = (\d+)$/m; $fsblocksize=$1; # multiline matching ^$ refers to individual lines...
/^agblocks = (\d+)$/m; $agblocks=$1; /^dblocks = (\d+)$/m; $fsblocks=$1;
/^agcount = (\d+)$/m; $agcount=$1; /^blocksize = (\d+)$/m; $fsblocksize=$1;
/^imax_pct = (\d+)$/m; $imax_pct=$1; /^agblocks = (\d+)$/m; $agblocks=$1;
/^logblocks = (\d+)$/m; $logblocks=$1; /^agcount = (\d+)$/m; $agcount=$1;
/^logstart = (\d+)$/m; $logstart=$1; /^imax_pct = (\d+)$/m; $imax_pct=$1;
$internal = $logstart > 0 ? " (internal)" : ""; /^logblocks = (\d+)$/m; $logblocks=$1;
/^logstart = (\d+)$/m; $logstart=$1;
$verbose && print STDERR <<"EOF" $internal = $logstart > 0 ? " (internal)" : "";
$verbose && print STDERR <<"EOF"
Filesystem information: Filesystem information:
type=$type; device=$dev type=$type; device=$dev
mount point=$mnt; mount options=$mnt_options mount point=$mnt; mount options=$mnt_options
@@ -122,6 +124,7 @@ Filesystem information:
total filesystem size (fs blocks)=$fsblocks; fs block size=$fsblocksize; imax_pct=$imax_pct total filesystem size (fs blocks)=$fsblocks; fs block size=$fsblocksize; imax_pct=$imax_pct
agcount=$agcount; agblocks=$agblocks; logblocks=$logblocks; logstart=$logstart$internal agcount=$agcount; agblocks=$agblocks; logblocks=$logblocks; logstart=$logstart$internal
EOF EOF
}
} }