File tree 1 file changed +16
-5
lines changed
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,27 @@ static int ok = EXIT_SUCCESS;
9
9
static void printsize (long long n )
10
10
{
11
11
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 ) {
14
17
n /= 1024 ;
15
18
unit = 'M' ;
16
19
}
17
- if (n > 1024 ) {
20
+
21
+ if (n > 1024 * 1024 * 10 ) {
18
22
n /= 1024 ;
19
23
unit = 'G' ;
20
24
}
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
+ }
22
33
}
23
34
24
35
static void df (char * s , int always ) {
@@ -41,7 +52,7 @@ static void df(char *s, int always) {
41
52
}
42
53
43
54
int df_main (int argc , char * argv []) {
44
- printf ("Filesystem Size Used Free Blksize\n" );
55
+ printf ("Filesystem Size Used Free Blksize\n" );
45
56
if (argc == 1 ) {
46
57
char s [2000 ];
47
58
FILE * f = fopen ("/proc/mounts" , "r" );
You can’t perform that action at this time.
0 commit comments