RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1527391 - ls ignores the -k option to show size in kibibytes
Summary: ls ignores the -k option to show size in kibibytes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: coreutils
Version: 7.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: Radka Brychtova
URL:
Whiteboard:
Depends On:
Blocks: 1549689 1551061
TreeView+ depends on / blocked
 
Reported: 2017-12-19 10:57 UTC by Zdenek Pytela
Modified: 2021-03-11 16:42 UTC (History)
5 users (show)

Fixed In Version: coreutils-8.22-24.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 13:06:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:2217 0 None None None 2019-08-06 13:06:28 UTC

Description Zdenek Pytela 2017-12-19 10:57:44 UTC
Description of problem:
coreutils 8.22 to 27 seem to ignore the "-k' option to display size in blocks of 1KiB when "-l" or similar option is used

Version-Release number of selected component (if applicable):
RHEL 7.0 to 7.4
coreutils-8.22-18.el7.x86_64 (no change in the package)

How reproducible:
always

Steps to Reproduce:
1. ls -lk /etc/passwd

Actual results:
-rw-r--r--. 1 root root 1508 Dec  6 09:27 /etc/passwd


Expected results:
-rw-r--r--. 1 root root 2 Dec 11 03:50 /etc/passwd


Additional info:
coreutils-8.4-47.el6.x86_64 from RHEL 6 and coreutils-5.97-34.el5_8.1 from RHEL 5 are okay
coreutils-8.25-17.fc25.x86_64 to coreutils-8.27-17.fc27.x86_64 suffer from the same issue

### sanity
unalias ls
### the same for switches reordered
$ ls -kl /etc/passwd
-rw-r--r--. 1 root root 1508 Dec  6 09:27 /etc/passwd
### correct for --human-readable, --si, and explicit blocksize
$ ls -lh /etc/passwd
-rw-r--r--. 1 root root 1.5K Dec  6 09:27 /etc/passwd
$ ls -l --si /etc/passwd
-rw-r--r--. 1 root root 1.6k Dec  6 09:27 /etc/passwd
$ ls -l --block-size=1k /etc/passwd
-rw-r--r--. 1 root root 2 Dec  6 09:27 /etc/passwd

see also ls info page:
‘-k’
‘--kibibytes’
     Set the default block size to its normal value of 1024 bytes,
     overriding any contrary specification in environment variables
     (*note Block size::).  This option is in turn overridden by the
     ‘--block-size’, ‘-h’ or ‘--human-readable’, and ‘--si’ options.

     The ‘-k’ or ‘--kibibytes’ option affects the per-directory block
     count written by the ‘-l’ and similar options, and the size written
     by the ‘-s’ or ‘--size’ option.  It does not affect the file size
     written by ‘-l’.

Comment 2 Kamil Dudka 2017-12-19 12:09:53 UTC
(In reply to Zdenek Pytela from comment #0)
> It does not affect the file size written by ‘-l’.

I believe that the above statement explains the observed behavior.  On the other hand, it seems to contradict the preceding sentence.  It seems to work fine with the -s option, where it overrides $BLOCKSIZE or $BLOCK_SIZE by the default value 1024.

The RHEL-7 behavior (as well as the documentation) matches the latest upstream.  I do not think we can change the behavior but we can improve the documentation.

Does this break any existing scripts or something?  Or is the only problem that it does not work as expected?

Comment 9 Kamil Dudka 2018-05-30 13:13:42 UTC
Sorry for the delay.  After reading the info documentation once again, I must admit that it is technically correct as it is, although it is not intuitive.

I propose to change it as follows:

    "This option is in turn overridden by the ‘--block-size’, ‘-h’ or
    ‘--human-readable’, and ‘--si’ options."

-->

    "If ‘--block-size’, ‘-h’, ‘--human-readable’, or ‘--si’ options are used,
    they take precedence over ‘-k’ or ‘--kibibytes’ even if ‘-k’ or ‘--kibibytes’
    is placed after the other options.

Would such a change help to avoid the confusion?

Note that by "per-directory block count written by the -l", they mean the first line of the output in the form "total NNNN".  Should this also be clarified?

Comment 12 Kamil Dudka 2018-12-06 13:34:31 UTC
I have proposed a documentation fix upstream:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33646

Comment 15 Kamil Dudka 2019-03-18 12:57:10 UTC
upstream commit:

https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=6bd78f27

Comment 18 errata-xmlrpc 2019-08-06 13:06:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2217


Note You need to log in before you can comment on or make changes to this bug.