X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=blobdiff_plain;f=util.c;h=56618b23a46a57e936a5ed31949d1c3d3b312c49;hp=5c70a8354dd78ad32de1c18ed1c3fb14cc1aa1ec;hb=56eb10c0b6e8f21540af444c8a28aa9e8f138ce6;hpb=9a9dab3670110c2db7fe6f716977b72adedbf855 diff --git a/util.c b/util.c index 5c70a835..56618b23 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; }