Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
30ea6a0a
Commit
30ea6a0a
authored
Feb 27, 2017
by
Leigh B Stoller
Browse files
Add options to display sizes in KB/MB instead of bytes.
parent
662700ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils/imageinfo.in
View file @
30ea6a0a
...
...
@@ -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:qr
U:
";
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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment