[Bug 9741] New: 'cat' broken for kernel < 3.0

bugzilla at busybox.net bugzilla at busybox.net
Mon Mar 13 21:01:47 UTC 2017


https://bugs.busybox.net/show_bug.cgi?id=9741

            Bug ID: 9741
           Summary: 'cat' broken for kernel < 3.0
           Product: Busybox
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: grant.b.edwards at gmail.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

The 'cat' utility fails on older kernel versions with multiple files
when stdout is a file.

In older kernel versions, the sendfile() system call that 'cat' uses
does not update the output file position.  When 'cat' stdout is a
file, this results in each input file overwriting the previous one:

   # ls -l
   total 12
   -rw-r--r--    1 root     root            29 Mar 13 17:44 d1
   -rw-r--r--    1 root     root            29 Mar 13 17:44 d2
   -rw-r--r--    1 root     root            29 Mar 13 17:44 d3

   # cat d1 d2 d3
   Mon Mar 13 17:44:35 UTC 2017
   Mon Mar 13 17:44:40 UTC 2017
   Mon Mar 13 17:44:43 UTC 2017

   # cat d1 d2 d3 >foo

   # ls -l
   total 16
   -rw-r--r--    1 root     root            29 Mar 13 17:44 d1
   -rw-r--r--    1 root     root            29 Mar 13 17:44 d2
   -rw-r--r--    1 root     root            29 Mar 13 17:44 d3
   -rw-r--r--    1 root     root            29 Mar 13 20:56 foo

   # cat foo
   Mon Mar 13 17:44:43 UTC 2017

   # cat d1 d2 d3 | cat >foo

   # ls -l foo
   -rw-r--r--    1 root     root            87 Mar 13 20:56 foo

   # cat foo
   Mon Mar 13 17:44:35 UTC 2017
   Mon Mar 13 17:44:40 UTC 2017
   Mon Mar 13 17:44:43 UTC 2017

I'm not sure exactly which kernel version breaks this.  It fails with
kernel 2.6.33, but is OK with 3.8.13.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list