kern

changeset 82:8b92b0c1c220

added decimal digits to the disk size output
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 Dec 2011 13:45:32 +0200
parents 9c979413cfbf
children 4ef83db5f4cd
files src/ata.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/src/ata.c	Tue Dec 06 13:37:11 2011 +0200
     1.2 +++ b/src/ata.c	Tue Dec 06 13:45:32 2011 +0200
     1.3 @@ -245,14 +245,16 @@
     1.4  {
     1.5  	static const char *suffix[] = {"kb", "mb", "gb", "tb", "pb", 0};
     1.6  	int i;
     1.7 +	unsigned int rem;
     1.8  
     1.9  	/* start with kilobytes */
    1.10  	nsect /= 2;
    1.11  
    1.12  	for(i=0; nsect >= 1024 && suffix[i + 1]; i++) {
    1.13 +		rem = nsect % 1024;
    1.14  		nsect /= 1024;
    1.15  	}
    1.16 -	sprintf(buf, "%u%s", (unsigned int)nsect, suffix[i]);
    1.17 +	sprintf(buf, "%u.%u%s", (unsigned int)nsect, 100 * rem / 1024, suffix[i]);
    1.18  	return buf;
    1.19  }
    1.20