mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
df was totally broken. So I fixed it.
-Erik
This commit is contained in:
parent
8d7bdc9deb
commit
7c3e7ac940
@ -39,6 +39,9 @@ static int df(char *device, const char *mountPoint)
|
|||||||
struct statfs s;
|
struct statfs s;
|
||||||
long blocks_used;
|
long blocks_used;
|
||||||
long blocks_percent_used;
|
long blocks_percent_used;
|
||||||
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
|
long divisor, base;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (statfs(mountPoint, &s) != 0) {
|
if (statfs(mountPoint, &s) != 0) {
|
||||||
perror_msg("%s", mountPoint);
|
perror_msg("%s", mountPoint);
|
||||||
@ -59,20 +62,38 @@ static int df(char *device, const char *mountPoint)
|
|||||||
find_real_root_device_name( device);
|
find_real_root_device_name( device);
|
||||||
}
|
}
|
||||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
printf("%-20s %9s %9s %9s %3ld%% %s\n",
|
switch (disp_hr) {
|
||||||
device,
|
case MEGABYTE:
|
||||||
format((s.f_blocks * s.f_bsize), disp_hr),
|
fprintf(stderr, "got MEGABYTE\n");
|
||||||
format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr),
|
divisor = KILOBYTE;
|
||||||
format(s.f_bavail * s.f_bsize, disp_hr),
|
base = KILOBYTE;
|
||||||
|
break;
|
||||||
|
case KILOBYTE:
|
||||||
|
fprintf(stderr, "got KILOBYTE\n");
|
||||||
|
divisor = KILOBYTE;
|
||||||
|
base = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "got something else\n");
|
||||||
|
divisor = KILOBYTE;
|
||||||
|
base = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%-20s %9s ", device,
|
||||||
|
format((s.f_blocks * (s.f_bsize / divisor)), base));
|
||||||
|
printf("%9s ",
|
||||||
|
format(((s.f_blocks - s.f_bfree) *
|
||||||
|
(s.f_bsize / divisor)), base));
|
||||||
|
printf("%9s %3ld%% %s\n",
|
||||||
|
format((s.f_bavail * (s.f_bsize / divisor)), 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",
|
||||||
device,
|
device,
|
||||||
(long) (s.f_blocks * s.f_bsize) / KILOBYTE,
|
(long) (s.f_blocks * (s.f_bsize / KILOBYTE)),
|
||||||
(long) ((s.f_blocks - s.f_bfree) * s.f_bsize) / KILOBYTE,
|
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / KILOBYTE)),
|
||||||
(long) (s.f_bavail * s.f_bsize) / KILOBYTE,
|
(long) (s.f_bavail * (s.f_bsize / KILOBYTE)),
|
||||||
blocks_percent_used, mountPoint);
|
blocks_percent_used, mountPoint);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
df.c
43
df.c
@ -39,6 +39,9 @@ static int df(char *device, const char *mountPoint)
|
|||||||
struct statfs s;
|
struct statfs s;
|
||||||
long blocks_used;
|
long blocks_used;
|
||||||
long blocks_percent_used;
|
long blocks_percent_used;
|
||||||
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
|
long divisor, base;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (statfs(mountPoint, &s) != 0) {
|
if (statfs(mountPoint, &s) != 0) {
|
||||||
perror_msg("%s", mountPoint);
|
perror_msg("%s", mountPoint);
|
||||||
@ -59,20 +62,38 @@ static int df(char *device, const char *mountPoint)
|
|||||||
find_real_root_device_name( device);
|
find_real_root_device_name( device);
|
||||||
}
|
}
|
||||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||||
printf("%-20s %9s %9s %9s %3ld%% %s\n",
|
switch (disp_hr) {
|
||||||
device,
|
case MEGABYTE:
|
||||||
format((s.f_blocks * s.f_bsize), disp_hr),
|
fprintf(stderr, "got MEGABYTE\n");
|
||||||
format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr),
|
divisor = KILOBYTE;
|
||||||
format(s.f_bavail * s.f_bsize, disp_hr),
|
base = KILOBYTE;
|
||||||
|
break;
|
||||||
|
case KILOBYTE:
|
||||||
|
fprintf(stderr, "got KILOBYTE\n");
|
||||||
|
divisor = KILOBYTE;
|
||||||
|
base = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "got something else\n");
|
||||||
|
divisor = KILOBYTE;
|
||||||
|
base = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%-20s %9s ", device,
|
||||||
|
format((s.f_blocks * (s.f_bsize / divisor)), base));
|
||||||
|
printf("%9s ",
|
||||||
|
format(((s.f_blocks - s.f_bfree) *
|
||||||
|
(s.f_bsize / divisor)), base));
|
||||||
|
printf("%9s %3ld%% %s\n",
|
||||||
|
format((s.f_bavail * (s.f_bsize / divisor)), 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",
|
||||||
device,
|
device,
|
||||||
(long) (s.f_blocks * s.f_bsize) / KILOBYTE,
|
(long) (s.f_blocks * (s.f_bsize / KILOBYTE)),
|
||||||
(long) ((s.f_blocks - s.f_bfree) * s.f_bsize) / KILOBYTE,
|
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / KILOBYTE)),
|
||||||
(long) (s.f_bavail * s.f_bsize) / KILOBYTE,
|
(long) (s.f_bavail * (s.f_bsize / KILOBYTE)),
|
||||||
blocks_percent_used, mountPoint);
|
blocks_percent_used, mountPoint);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user