summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2002-03-15 05:21:36 +0000
committerNeil Brown <neilb@suse.de>2002-03-15 05:21:36 +0000
commit56eb10c0b6e8f21540af444c8a28aa9e8f138ce6 (patch)
tree3b791ce573cca8c746f318411cb63d8c677678a1 /util.c
parent9a9dab3670110c2db7fe6f716977b72adedbf855 (diff)
downloadmdadm-56eb10c0b6e8f21540af444c8a28aa9e8f138ce6.tar.gz
mdadm-56eb10c0b6e8f21540af444c8a28aa9e8f138ce6.tar.xz
mdadm-56eb10c0b6e8f21540af444c8a28aa9e8f138ce6.zip
mdadm-0.7.1mdadm-0.7.1
Diffstat (limited to 'util.c')
-rw-r--r--util.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/util.c b/util.c
index 5c70a83..56618b2 100644
--- a/util.c
+++ b/util.c
@@ -412,7 +412,7 @@ char *map_dev(int major, int minor)
int calc_sb_csum(mdp_super_t *super)
{
unsigned int oldcsum = super->sb_csum;
- unsigned long long newcsum = 0; /* FIXME why does this make it work?? */
+ unsigned long long newcsum = 0;
unsigned long csum;
int i;
unsigned int *superc = (int*) super;
@@ -425,15 +425,26 @@ int calc_sb_csum(mdp_super_t *super)
return csum;
}
-char *human_size(long kbytes)
+char *human_size(long long bytes)
{
static char buf[30];
+
- if (kbytes < 2000)
+ if (bytes < 5000*1024)
buf[0]=0;
- else if (kbytes < 2*1024*1024)
- sprintf(buf, " (%d MiB)", kbytes>>10);
+ else if (bytes < 2*1024LL*1024LL*1024LL)
+ sprintf(buf, " (%d.%02d MiB %d.%02d MB)",
+ (long)(bytes>>20),
+ (long)(bytes&0xfffff)/(0x100000/100),
+ (long)(bytes/1000/1000),
+ (long)((bytes%1000000)/10000)
+ );
else
- sprintf(buf, " (%d GiB)", kbytes>>20);
+ sprintf(buf, " (%d.%02d GiB %d.%02d GB)",
+ (long)(bytes>>30),
+ (long)((bytes>>10)&0xfffff)/(0x100000/100),
+ (long)(bytes/1000LL/1000LL/1000LL),
+ (long)(((bytes/1000)%1000000)/10000)
+ );
return buf;
}