summaryrefslogtreecommitdiff
path: root/coreutils/dd.c
diff options
context:
space:
mode:
authorMatt Kraai2002-02-05 15:28:54 +0000
committerMatt Kraai2002-02-05 15:28:54 +0000
commiteb83478528c46edf140194f7c612f6beedb60929 (patch)
treef75b9dafaac15a878b49aaa6c58af6787e8d52c8 /coreutils/dd.c
parent369da77d5eb818e7a6f1e5e5829a4066e7785680 (diff)
downloadbusybox-eb83478528c46edf140194f7c612f6beedb60929.zip
busybox-eb83478528c46edf140194f7c612f6beedb60929.tar.gz
* fileutils/dd.c (dd_main): Ignore ftruncate error if the output is not a
file or directory.
Diffstat (limited to 'coreutils/dd.c')
-rw-r--r--coreutils/dd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 818ab77..09e6ccc 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -22,6 +22,7 @@
*/
#include <sys/types.h>
+#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -106,8 +107,13 @@ int dd_main(int argc, char **argv)
perror_msg_and_die("%s", outfile);
if (seek && trunc) {
- if (ftruncate(ofd, seek * bs) < 0)
- perror_msg_and_die("%s", outfile);
+ if (ftruncate(ofd, seek * bs) < 0) {
+ struct stat st;
+
+ if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
+ S_ISDIR (st.st_mode))
+ perror_msg_and_die("%s", outfile);
+ }
}
} else {
ofd = STDOUT_FILENO;