aboutsummaryrefslogtreecommitdiff
path: root/toys/other/mountpoint.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/other/mountpoint.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/other/mountpoint.c')
-rw-r--r--toys/other/mountpoint.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/toys/other/mountpoint.c b/toys/other/mountpoint.c
index 1bb0b3a7..fe63b725 100644
--- a/toys/other/mountpoint.c
+++ b/toys/other/mountpoint.c
@@ -17,19 +17,20 @@ config MOUNTPOINT
-x Print major/minor device number of the block device
*/
+#define FOR_mountpoint
#include "toys.h"
void mountpoint_main(void)
{
struct stat st1, st2;
int res = 0;
- int quiet = toys.optflags & 0x4;
+ int quiet = toys.optflags & FLAG_q;
toys.exitval = 1; // be pessimistic
strncpy(toybuf, toys.optargs[0], sizeof(toybuf));
- if (((toys.optflags & 0x1) && lstat(toybuf, &st1)) || stat(toybuf, &st1))
+ if (((toys.optflags & FLAG_x) && lstat(toybuf, &st1)) || stat(toybuf, &st1))
perror_exit("%s", toybuf);
- if (toys.optflags & 0x1){
+ if (toys.optflags & FLAG_x){
if (S_ISBLK(st1.st_mode)) {
if (!quiet) printf("%u:%u\n", major(st1.st_rdev), minor(st1.st_rdev));
toys.exitval = 0;
@@ -48,7 +49,7 @@ void mountpoint_main(void)
res = (st1.st_dev != st2.st_dev) ||
(st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
if (!quiet) printf("%s is %sa mountpoint\n", toys.optargs[0], res ? "" : "not ");
- if (toys.optflags & 0x2)
+ if (toys.optflags & FLAG_d)
printf("%u:%u\n", major(st1.st_dev), minor(st1.st_dev));
toys.exitval = res ? 0 : 1;
}