diff options
-rw-r--r-- | toys/other/readlink.c | 16 | ||||
-rw-r--r-- | toys/other/realpath.c | 26 | ||||
-rw-r--r-- | toys/posix/df.c | 2 |
3 files changed, 17 insertions, 27 deletions
diff --git a/toys/other/readlink.c b/toys/other/readlink.c index 9ebf68d7..bae09536 100644 --- a/toys/other/readlink.c +++ b/toys/other/readlink.c @@ -3,6 +3,7 @@ * Copyright 2007 Rob Landley <rob@landley.net> USE_READLINK(NEWTOY(readlink, "<1nqmef(canonicalize)[-mef]", TOYFLAG_USR|TOYFLAG_BIN)) +USE_REALPATH(NEWTOY(realpath, "<1", TOYFLAG_USR|TOYFLAG_BIN)) config READLINK bool "readlink" @@ -19,9 +20,18 @@ config READLINK -m Ignore missing entries, show where it would be -n No trailing newline -q Quiet (no output, just error code) + +config REALPATH + bool "realpath" + default y + help + usage: realpath FILE... + + Display the canonical absolute pathname */ #define FOR_readlink +#define FORCE_FLAGS #include "toys.h" void readlink_main(void) @@ -41,3 +51,9 @@ void readlink_main(void) } else toys.exitval = 1; } } + +void realpath_main(void) +{ + toys.optflags = FLAG_f; + readlink_main(); +} diff --git a/toys/other/realpath.c b/toys/other/realpath.c deleted file mode 100644 index 8f75d3f2..00000000 --- a/toys/other/realpath.c +++ /dev/null @@ -1,26 +0,0 @@ -/* realpath.c - Return the canonical version of a pathname - * - * Copyright 2012 Andre Renaud <andre@bluewatersys.com> - -USE_REALPATH(NEWTOY(realpath, "<1", TOYFLAG_USR|TOYFLAG_BIN)) - -config REALPATH - bool "realpath" - default y - help - usage: realpath FILE... - - Display the canonical absolute pathname -*/ - -#include "toys.h" - -void realpath_main(void) -{ - char **s = toys.optargs; - - for (s = toys.optargs; *s; s++) { - if (!realpath(*s, toybuf)) perror_msg_raw(*s); - else xputs(toybuf); - } -} diff --git a/toys/posix/df.c b/toys/posix/df.c index a93a762c..e1fd35f4 100644 --- a/toys/posix/df.c +++ b/toys/posix/df.c @@ -134,7 +134,7 @@ static void show_mt(struct mtab_list *mt, int measuring) if (used*100 != percent*(used+avail)) percent++; } - device = *mt->device == '/' ? realpath(mt->device, NULL) : NULL; + device = *mt->device == '/' ? xabspath(mt->device, 0) : NULL; if (!device) device = mt->device; if (measuring) { |