lspart

changeset 1:3bd9cfd79fc0

fixed the size calculation
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 14 Oct 2011 20:41:13 +0300
parents 29d89c00e611
children 99bb8b4ef1bc
files lspart.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/lspart.c	Fri Oct 14 07:45:44 2011 +0300
     1.2 +++ b/lspart.c	Fri Oct 14 20:41:13 2011 +0300
     1.3 @@ -200,18 +200,20 @@
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 -const char *printsz(unsigned int sz)
     1.8 +const char *printsz(unsigned int sz_sect)
     1.9  {
    1.10  	int i = 0;
    1.11  	const char *suffix[] = { "kb", "mb", "gb", "tb", "pb", 0 };
    1.12  	static char buf[512];
    1.13  
    1.14 -	while(sz > 1024 && suffix[i + 1]) {
    1.15 -		sz /= 1024;
    1.16 +	float sz = (float)sz_sect / 2.0;
    1.17 +
    1.18 +	while(sz > 1024.0 && suffix[i + 1]) {
    1.19 +		sz /= 1024.0;
    1.20  		i++;
    1.21  	}
    1.22  
    1.23 -	sprintf(buf, "%u %s", sz, suffix[i]);
    1.24 +	sprintf(buf, "%.1f %s", sz, suffix[i]);
    1.25  	return buf;
    1.26  }
    1.27