diff options
author | Rob Landley <rob@landley.net> | 2014-09-14 12:29:44 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-09-14 12:29:44 -0500 |
commit | 360d57f843f5435a75270e54583430dcb8f62546 (patch) | |
tree | 2e043033414a0cb03b6eb86b3b662f7ca9571788 /toys | |
parent | e1366f02fea3cb035cc4ed0b59d12f1962b6ebfd (diff) | |
download | toybox-360d57f843f5435a75270e54583430dcb8f62546.tar.gz |
Split xpopen() into xpopen_both(), xpopen(), and xrun() depending on whether we want to redirect both, one, or neither of stdin/stdout.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/lsb/mount.c | 19 | ||||
-rw-r--r-- | toys/other/inotifyd.c | 2 | ||||
-rw-r--r-- | toys/posix/cp.c | 3 | ||||
-rw-r--r-- | toys/posix/find.c | 2 |
4 files changed, 17 insertions, 9 deletions
diff --git a/toys/lsb/mount.c b/toys/lsb/mount.c index 949fb05d..39d98caf 100644 --- a/toys/lsb/mount.c +++ b/toys/lsb/mount.c @@ -7,6 +7,7 @@ * no mtab (/proc/mounts does it) so -n is NOP. USE_MOUNT(NEWTOY(mount, "?O:afnrvwt:o*[-rw]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT)) +USE_NFSMOUNT(NEWTOY(nfsmount, "?<2>2", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT)) config MOUNT bool "mount" @@ -32,6 +33,14 @@ config MOUNT bind mounts (file on file, directory on directory), so you don't need to say --bind or --loop. You can also "mount -a /path" to mount everything in /etc/fstab under /path, even if it's noauto. + +config NFSMOUNT + bool "nfsmount" + default n + help + usage: nfsmount SHARE DIR + + Invoke an eldrich horror from the dawn of time. */ #define FOR_mount @@ -155,7 +164,7 @@ static void mount_filesystem(char *dev, char *dir, char *type, } else fp = xfopen("/proc/filesystems", "r"); } else if (!strcmp(type, "ignore")) return; else if (!strcmp(type, "swap")) - toys.exitval |= xpclose(xpopen((char *[]){"swapon", "--", dev, 0}, 0), 0); + toys.exitval |= xrun((char *[]){"swapon", "--", dev, 0}); for (;;) { char *buf = 0; @@ -204,13 +213,13 @@ static void mount_filesystem(char *dev, char *dir, char *type, if (errno == ENOTBLK) { char *losetup[] = {"losetup", "-fs", dev, 0}; - int pipes[2], len; + int pipe, len; pid_t pid; if (flags & MS_RDONLY) losetup[1] = "-fsr"; - pid = xpopen(losetup, pipes); - len = readall(pipes[1], toybuf, sizeof(toybuf)-1); - rc = xpclose(pid, pipes); + pid = xpopen(losetup, &pipe, 1); + len = readall(pipe, toybuf, sizeof(toybuf)-1); + rc = xpclose(pid, pipe); if (!rc && len > 1) { if (toybuf[len-1] == '\n') --len; toybuf[len] = 0; diff --git a/toys/other/inotifyd.c b/toys/other/inotifyd.c index 59c9a50c..f2e11ca4 100644 --- a/toys/other/inotifyd.c +++ b/toys/other/inotifyd.c @@ -104,7 +104,7 @@ void inotifyd_main(void) prog_args[1] = toybuf; prog_args[2] = toys.optargs[event->wd]; prog_args[3] = event->len ? event->name : 0; - xpclose(xpopen(prog_args, 0), 0); + xrun(prog_args); } if (event->mask & IN_IGNORED) { diff --git a/toys/posix/cp.c b/toys/posix/cp.c index d79819b2..d73b7229 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -341,8 +341,7 @@ static int install_node(struct dirtree *try) // No -r so always one level deep, so destname as set by cp_node() is correct if (toys.optflags & FLAG_s) - if (xpclose(xpopen((char *[]){"strip", "-p", TT.destname, 0}, 0), 0)) - toys.exitval = 1; + if (xrun((char *[]){"strip", "-p", TT.destname, 0})) toys.exitval = 1; return 0; } diff --git a/toys/posix/find.c b/toys/posix/find.c index b74cb88e..9f679a02 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -102,7 +102,7 @@ static int flush_exec(struct dirtree *new, struct exec_range *aa) newargs[pos+rest] = 0; } - rc = xpclose(xpopen(newargs, 0), 0); + rc = xrun(newargs); llist_traverse(*dl, llist_free_double); *dl = 0; |