diff options
author | Rob Landley <rob@landley.net> | 2016-08-04 10:16:59 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-08-04 10:16:59 -0500 |
commit | 027a73a903af306449710ce12bc09e0e3550c6c9 (patch) | |
tree | a415cb11fa6f2b34e63b8259fc52342aaa8fec75 /toys/pending/dd.c | |
parent | 145b7024b5fbb74f16d5e403fb004ff8209bc4a0 (diff) | |
download | toybox-027a73a903af306449710ce12bc09e0e3550c6c9.tar.gz |
Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout,
add xopenro() that takes one argument and understands "-" means stdin,
and switch over lots of users.
Diffstat (limited to 'toys/pending/dd.c')
-rw-r--r-- | toys/pending/dd.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/toys/pending/dd.c b/toys/pending/dd.c index 9990a0f4..b09a7dfe 100644 --- a/toys/pending/dd.c +++ b/toys/pending/dd.c @@ -143,16 +143,6 @@ static void status() } } -static int xmove_fd(int fd) -{ - int newfd; - - if (fd > STDERR_FILENO) return fd; - if ((newfd = fcntl(fd, F_DUPFD, 3) < 0)) perror_exit("dupfd IO"); - close(fd); - return newfd; -} - static void setup_inout() { /* for C_BS, in/out is done as it is. so only in.sz is enough. @@ -164,10 +154,8 @@ static void setup_inout() if (!TT.in.name) { TT.in.name = "stdin"; TT.in.fd = STDIN_FILENO; - } else { - TT.in.fd = xopen(TT.in.name, O_RDONLY); - TT.in.fd = xmove_fd(TT.in.fd); - } + } else TT.in.fd = xopenro(TT.in.name); + //setup outout if (!TT.out.name) { TT.out.name = "stdout"; @@ -176,7 +164,6 @@ static void setup_inout() int flags = O_WRONLY|O_CREAT; if (!(toys.optflags&C_NOTRUNC)) flags |= O_TRUNC; TT.out.fd = xcreate(TT.out.name, flags, 0666); - TT.out.fd = xmove_fd(TT.out.fd); } if (TT.in.offset) { |