mirror of
https://github.com/sheumann/hush.git
synced 2024-11-05 06:07:00 +00:00
Fix up df so it works properly
-Erik
This commit is contained in:
parent
651f8c04ef
commit
5986f8d1c6
@ -40,7 +40,7 @@ static int df(char *device, const char *mountPoint)
|
|||||||
long blocks_used;
|
long blocks_used;
|
||||||
long blocks_percent_used;
|
long blocks_percent_used;
|
||||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
long divisor, base;
|
long base;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (statfs(mountPoint, &s) != 0) {
|
if (statfs(mountPoint, &s) != 0) {
|
||||||
@ -61,28 +61,23 @@ static int df(char *device, const char *mountPoint)
|
|||||||
* or leaves device alone if it can't find it */
|
* or leaves device alone if it can't find it */
|
||||||
find_real_root_device_name( device);
|
find_real_root_device_name( device);
|
||||||
}
|
}
|
||||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
switch (disp_hr) {
|
switch (disp_hr) {
|
||||||
case MEGABYTE:
|
case MEGABYTE:
|
||||||
divisor = KILOBYTE;
|
|
||||||
base = KILOBYTE;
|
base = KILOBYTE;
|
||||||
break;
|
break;
|
||||||
case KILOBYTE:
|
case KILOBYTE:
|
||||||
divisor = KILOBYTE;
|
|
||||||
base = 1;
|
base = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
divisor = KILOBYTE;
|
|
||||||
base = 0;
|
base = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%-20s %9s ", device,
|
printf("%-20s %9s ", device,
|
||||||
format((s.f_blocks * (s.f_bsize / divisor)), base));
|
format(s.f_blocks * (s.f_bsize/KILOBYTE), base));
|
||||||
printf("%9s ",
|
printf("%9s ",
|
||||||
format(((s.f_blocks - s.f_bfree) *
|
format((s.f_blocks - s.f_bfree) * (s.f_bsize/KILOBYTE), base));
|
||||||
(s.f_bsize / divisor)), base));
|
|
||||||
printf("%9s %3ld%% %s\n",
|
printf("%9s %3ld%% %s\n",
|
||||||
format((s.f_bavail * (s.f_bsize / divisor)), base),
|
format(s.f_bavail * (s.f_bsize/KILOBYTE), base),
|
||||||
blocks_percent_used, mountPoint);
|
blocks_percent_used, mountPoint);
|
||||||
#else
|
#else
|
||||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||||
|
15
df.c
15
df.c
@ -40,7 +40,7 @@ static int df(char *device, const char *mountPoint)
|
|||||||
long blocks_used;
|
long blocks_used;
|
||||||
long blocks_percent_used;
|
long blocks_percent_used;
|
||||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
long divisor, base;
|
long base;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (statfs(mountPoint, &s) != 0) {
|
if (statfs(mountPoint, &s) != 0) {
|
||||||
@ -61,28 +61,23 @@ static int df(char *device, const char *mountPoint)
|
|||||||
* or leaves device alone if it can't find it */
|
* or leaves device alone if it can't find it */
|
||||||
find_real_root_device_name( device);
|
find_real_root_device_name( device);
|
||||||
}
|
}
|
||||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
switch (disp_hr) {
|
switch (disp_hr) {
|
||||||
case MEGABYTE:
|
case MEGABYTE:
|
||||||
divisor = KILOBYTE;
|
|
||||||
base = KILOBYTE;
|
base = KILOBYTE;
|
||||||
break;
|
break;
|
||||||
case KILOBYTE:
|
case KILOBYTE:
|
||||||
divisor = KILOBYTE;
|
|
||||||
base = 1;
|
base = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
divisor = KILOBYTE;
|
|
||||||
base = 0;
|
base = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%-20s %9s ", device,
|
printf("%-20s %9s ", device,
|
||||||
format((s.f_blocks * (s.f_bsize / divisor)), base));
|
format(s.f_blocks * (s.f_bsize/KILOBYTE), base));
|
||||||
printf("%9s ",
|
printf("%9s ",
|
||||||
format(((s.f_blocks - s.f_bfree) *
|
format((s.f_blocks - s.f_bfree) * (s.f_bsize/KILOBYTE), base));
|
||||||
(s.f_bsize / divisor)), base));
|
|
||||||
printf("%9s %3ld%% %s\n",
|
printf("%9s %3ld%% %s\n",
|
||||||
format((s.f_bavail * (s.f_bsize / divisor)), base),
|
format(s.f_bavail * (s.f_bsize/KILOBYTE), base),
|
||||||
blocks_percent_used, mountPoint);
|
blocks_percent_used, mountPoint);
|
||||||
#else
|
#else
|
||||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user