On Fri, Oct 3, 2014 at 9:48 AM, Pádraig Brady <p...@draigbrady.com> wrote: > On 10/03/2014 03:47 PM, George Shuklin wrote: ... > I'm not sure where the above code comes from, > by coreutils trunk has the same behavior with these files. > We could avoid it with the following patch. > Note in the case where "real" small files don't > take up space in the file system, this will involve a redundant read, > however that will only be the case for small files so shouldn't > be problematic. > > thanks, > Pádraig. > > diff --git a/src/wc.c b/src/wc.c > index 1ff007d..bf1ce76 100644 > --- a/src/wc.c > +++ b/src/wc.c > @@ -235,6 +235,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) > fstatus->failed = fstat (fd, &fstatus->st); > > if (! fstatus->failed && S_ISREG (fstatus->st.st_mode) > + && fstatus->st.st_blocks > && (current_pos = lseek (fd, 0, SEEK_CUR)) != -1 > && (end_pos = lseek (fd, 0, SEEK_END)) != -1) > {
That looks like a fine fix. However, a similar issue affects tac, when its lseek-SEEK_END fails: $ tac /sys/kernel/vmcoreinfo tac: /sys/kernel/vmcoreinfo: read error: Inappropriate ioctl for device