File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,16 +9,27 @@ static int ok = EXIT_SUCCESS;
99static void printsize (long long n )
1010{
1111 char unit = 'K' ;
12- n /= 1024 ;
13- if (n > 1024 ) {
12+ long long t ;
13+
14+ n *= 10 ;
15+
16+ if (n > 1024 * 1024 * 10 ) {
1417 n /= 1024 ;
1518 unit = 'M' ;
1619 }
17- if (n > 1024 ) {
20+
21+ if (n > 1024 * 1024 * 10 ) {
1822 n /= 1024 ;
1923 unit = 'G' ;
2024 }
21- printf ("%4lld%c" , n , unit );
25+
26+ t = (n + 512 ) / 1024 ;
27+ if (t %10 != 0 ) {
28+ printf ("%4lld.%1lld%c" , t /10 , t %10 , unit );
29+ }
30+ else {
31+ printf ("%4lld%c" , t /10 , unit );
32+ }
2233}
2334
2435static void df (char * s , int always ) {
@@ -41,7 +52,7 @@ static void df(char *s, int always) {
4152}
4253
4354int df_main (int argc , char * argv []) {
44- printf ("Filesystem Size Used Free Blksize\n" );
55+ printf ("Filesystem Size Used Free Blksize\n" );
4556 if (argc == 1 ) {
4657 char s [2000 ];
4758 FILE * f = fopen ("/proc/mounts" , "r" );
You can’t perform that action at this time.
0 commit comments