From eb83478528c46edf140194f7c612f6beedb60929 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Tue, 5 Feb 2002 15:28:54 +0000 Subject: [PATCH] * fileutils/dd.c (dd_main): Ignore ftruncate error if the output is not a file or directory. --- coreutils/dd.c | 10 ++++++++-- 1 file 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 @@ */ #include +#include #include #include #include @@ -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; -- 2.25.1