emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#18621: closed ([BUG] wc -c incorrectly counts byte


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#18621: closed ([BUG] wc -c incorrectly counts bytes in /sys)
Date: Tue, 07 Oct 2014 23:53:02 +0000

Your message dated Tue, 07 Oct 2014 16:51:47 -0700
with message-id <address@hidden>
and subject line Re: bug#18621: [BUG] wc -c incorrectly counts bytes in /sys
has caused the debbugs.gnu.org bug report #18621,
regarding [BUG] wc -c incorrectly counts bytes in /sys
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
18621: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18621
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [BUG] wc -c incorrectly counts bytes in /sys Date: Fri, 03 Oct 2014 17:47:19 +0300 User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 There is many sysfs (linux) attributes which reported as '4k files' but contains just a few bytes.

wc file and wc -c shows different sizes.

Example:

$cat /sys/kernel/vmcoreinfo
1b74c00 1024

$hexdump -Cv /sys/kernel/vmcoreinfo
00000000  31 62 37 34 63 30 30 20  31 30 32 34 0a           |1b74c00 1024.|
0000000d

$ls -la /sys/kernel/vmcoreinfo
-r--r--r-- 1 root root 4096 Oct  3 17:40 /sys/kernel/vmcoreinfo


Here wc output:

$ wc /sys/kernel/vmcoreinfo
   1    2   13 /sys/kernel/vmcoreinfo

and wc -c:

$ wc -c /sys/kernel/vmcoreinfo
4096 /sys/kernel/vmcoreinfo

4096 is not 13, and manual page for wc says that third number is byte count.

I think problem is in  cnt(const char *file)  function:

        if (dochar || domulti) {
                if (fstat(fd, &sb)) {
                        warn("%s: fstat", file);
                        (void)close(fd);
                        return (1);
                }
                if (S_ISREG(sb.st_mode)) {
                        (void)printf(" %7lld", (long long)sb.st_size);
                        tcharct += sb.st_size;
                        (void)close(fd);
                        return (0);
                }
        }





--- End Message ---
--- Begin Message --- Subject: Re: bug#18621: [BUG] wc -c incorrectly counts bytes in /sys Date: Tue, 07 Oct 2014 16:51:47 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2
Paul Eggert wrote:

The attached patch still needs a changelog entry and test cases.

I wrote those up and pushed the attached patch; this should fix the bug so I'm closing the bug report.

Attachment: 0001-wc-don-t-miscount-sys-and-similar-file-systems.patch
Description: Text document


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]