Some OSes, like linux 2.4.0, won't permit this.
Details at
http://boudicca.tux.org/hypermail/linux-kernel/latest/0857.html
Patch attached.

LLaP
bero

--- fileutils-4.0.35/src/dd.c.trunc     Wed Jan 10 16:37:04 2001
+++ fileutils-4.0.35/src/dd.c   Wed Jan 10 16:39:12 2001
@@ -1102,6 +1102,7 @@
 {
   int i;
   int exit_status;
+  struct stat stat_buf;
 
   program_name = argv[0];
   setlocale (LC_ALL, "");
@@ -1149,6 +1150,10 @@
          && open_fd (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0)
        error (1, errno, _("opening %s"), quote (output_file));
+       if(fstat(STDOUT_FILENO, &stat_buf)<0)
+               error(1, errno, "%s", output_file);
+       if(!S_ISREG(stat_buf.st_mode))
+               conversions_mask |= C_NOTRUNC;

 #if HAVE_FTRUNCATE
       if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
        {

Reply via email to