aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/df.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-10-08 00:02:30 -0500
committerRob Landley <rob@landley.net>2012-10-08 00:02:30 -0500
commitc0e56edaf256adb6c60c5a052525a1ffbb927901 (patch)
treed6bcc5c181ca46910a12d4dece4b26d6c71be3e1 /toys/posix/df.c
parentdc7a77d1940858495f76998f4d13cac9f73e0226 (diff)
downloadtoybox-c0e56edaf256adb6c60c5a052525a1ffbb927901.tar.gz
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Diffstat (limited to 'toys/posix/df.c')
-rw-r--r--toys/posix/df.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/toys/posix/df.c b/toys/posix/df.c
index e889907d..dc87fda3 100644
--- a/toys/posix/df.c
+++ b/toys/posix/df.c
@@ -37,16 +37,15 @@ config DF_PEDANTIC
-k Sets units back to 1024 bytes (the default without -P)
*/
+#define FOR_df
#include "toys.h"
-DEFINE_GLOBALS(
+GLOBALS(
struct arg_list *fstype;
long units;
)
-#define TT this.df
-
static void show_mt(struct mtab_list *mt)
{
int len;
@@ -67,7 +66,7 @@ static void show_mt(struct mtab_list *mt)
}
// If we don't have -a, skip synthetic filesystems
- if (!(toys.optflags & 1) && !mt->statvfs.f_blocks) return;
+ if (!(toys.optflags & FLAG_a) && !mt->statvfs.f_blocks) return;
// Figure out how much total/used/free space this filesystem has,
// forcing 64-bit math because filesystems are big now.
@@ -83,7 +82,7 @@ static void show_mt(struct mtab_list *mt)
// Figure out appropriate spacing
len = 25 - strlen(mt->device);
if (len < 1) len = 1;
- if (CFG_DF_PEDANTIC && (toys.optflags & 8)) {
+ if (CFG_DF_PEDANTIC && (toys.optflags & FLAG_P)) {
printf("%s %ld %ld %ld %ld%% %s\n", mt->device, size, used, avail,
percent, mt->dir);
} else {
@@ -98,9 +97,9 @@ void df_main(void)
// Handle -P and -k
TT.units = 1024;
- if (CFG_DF_PEDANTIC && (toys.optflags & 8)) {
+ if (CFG_DF_PEDANTIC && (toys.optflags & FLAG_P)) {
// Units are 512 bytes if you select "pedantic" without "kilobytes".
- if ((toys.optflags&3) == 1) TT.units = 512;
+ if ((toys.optflags&(FLAG_P|FLAG_k)) == FLAG_P) TT.units = 512;
printf("Filesystem %ld-blocks Used Available Capacity Mounted on\n",
TT.units);
} else puts("Filesystem\t1K-blocks\tUsed Available Use% Mounted on");