Commit 30ea6a0a authored by Leigh B Stoller's avatar Leigh B Stoller

Add options to display sizes in KB/MB instead of bytes.

parent 662700ba
......@@ -25,6 +25,7 @@ use English;
use strict;
use Getopt::Std;
use File::stat;
use bigint;
#
# Get basic info for an image.
......@@ -45,10 +46,11 @@ sub usage()
" -u Print just the uncompressed data size of the image (if available)\n".
" -m Print just the modtime of the image in seconds since epoch\n".
" -r Print the range of sectors covered by the image\n".
" -U k|m Show sizes in KB or MB instead of bytes\n".
" -x Show delta image info instead of full image info\n");
exit(-1);
}
my $optlist = "dsumN:qr";
my $optlist = "dsumN:qrU:";
my $debug = 0;
my $quiet = 0;
my $forcedelta= 0;
......@@ -57,6 +59,7 @@ my $showsize = 0;
my $showusize = 0;
my $showmtime = 0;
my $showrange = 0;
my $units;
my $nodeid;
#
......@@ -112,6 +115,12 @@ if (defined($options{"q"})) {
if (defined($options{"x"})) {
$forcedelta = 1;
}
if (defined($options{"U"})) {
$units = $options{"U"};
if ($units ne "k" && $units ne "m") {
usage();
}
}
if (defined($options{"s"})) {
$showsize = 1;
$showall = $showusize = $showmtime = $showrange = 0;
......@@ -241,6 +250,17 @@ if (!defined($nodeid)) {
}
}
if (defined($units)) {
if ($units eq "k") {
$isize = $isize / 1024;
$usize = $usize / 1024;
}
elsif ($units eq "m") {
$isize = $isize / (1024 * 1024);
$usize = $usize / (1024 * 1024);
}
}
if ($showall) {
if (defined($isize)) {
printf "size=%lu\n", $isize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment