aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2002-02-05 15:28:54 +0000
committerMatt Kraai <kraai@debian.org>2002-02-05 15:28:54 +0000
commiteb83478528c46edf140194f7c612f6beedb60929 (patch)
treef75b9dafaac15a878b49aaa6c58af6787e8d52c8
parent369da77d5eb818e7a6f1e5e5829a4066e7785680 (diff)
downloadbusybox-w32-eb83478528c46edf140194f7c612f6beedb60929.tar.gz
busybox-w32-eb83478528c46edf140194f7c612f6beedb60929.tar.bz2
busybox-w32-eb83478528c46edf140194f7c612f6beedb60929.zip
* fileutils/dd.c (dd_main): Ignore ftruncate error if the output is not a
file or directory.
-rw-r--r--coreutils/dd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 818ab777e..09e6cccc7 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/stat.h>
25#include <stdlib.h> 26#include <stdlib.h>
26#include <stdio.h> 27#include <stdio.h>
27#include <unistd.h> 28#include <unistd.h>
@@ -106,8 +107,13 @@ int dd_main(int argc, char **argv)
106 perror_msg_and_die("%s", outfile); 107 perror_msg_and_die("%s", outfile);
107 108
108 if (seek && trunc) { 109 if (seek && trunc) {
109 if (ftruncate(ofd, seek * bs) < 0) 110 if (ftruncate(ofd, seek * bs) < 0) {
110 perror_msg_and_die("%s", outfile); 111 struct stat st;
112
113 if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
114 S_ISDIR (st.st_mode))
115 perror_msg_and_die("%s", outfile);
116 }
111 } 117 }
112 } else { 118 } else {
113 ofd = STDOUT_FILENO; 119 ofd = STDOUT_FILENO;