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
# $fsblocks, $fsblocksize, $agblocks, $agcount, $imax_pct, $logblocks
# $logstart, $internal
@mtab = split(/ +/);
$mnt_options = $mtab[3];
- # xfs_db: read only, use the default superblock, print everything
- die("Error: $progname: can't read device: \"$dev\"\n") if (! -r $dev);
- $_=`xfs_db -r -c sb -c p $dev`;
- # multiline matching ^$ refers to individual lines...
- /^dblocks = (\d+)$/m; $fsblocks=$1;
- /^blocksize = (\d+)$/m; $fsblocksize=$1;
- /^agblocks = (\d+)$/m; $agblocks=$1;
- /^agcount = (\d+)$/m; $agcount=$1;
- /^imax_pct = (\d+)$/m; $imax_pct=$1;
- /^logblocks = (\d+)$/m; $logblocks=$1;
- /^logstart = (\d+)$/m; $logstart=$1;
- $internal = $logstart > 0 ? " (internal)" : "";
-
- $verbose && print STDERR <<"EOF"
+ # if we're running as root run xfs_db on the filesystem
+ if ($> == 0) {
+ # xfs_db: read only, use the default superblock, print everything
+ die("Error: $progname: can't read device: \"$dev\"\n") if (! -r $dev);
+ $_=`xfs_db -r -c sb -c p $dev`;
+ # multiline matching ^$ refers to individual lines...
+ /^dblocks = (\d+)$/m; $fsblocks=$1;
+ /^blocksize = (\d+)$/m; $fsblocksize=$1;
+ /^agblocks = (\d+)$/m; $agblocks=$1;
+ /^agcount = (\d+)$/m; $agcount=$1;
+ /^imax_pct = (\d+)$/m; $imax_pct=$1;
+ /^logblocks = (\d+)$/m; $logblocks=$1;
+ /^logstart = (\d+)$/m; $logstart=$1;
+ $internal = $logstart > 0 ? " (internal)" : "";
+
+ $verbose && print STDERR <<"EOF"
Filesystem information:
type=$type; device=$dev
mount point=$mnt; mount options=$mnt_options
total filesystem size (fs blocks)=$fsblocks; fs block size=$fsblocksize; imax_pct=$imax_pct
agcount=$agcount; agblocks=$agblocks; logblocks=$logblocks; logstart=$logstart$internal
EOF
+ }
}