Skip to content

ls: --colors=always -l . calls llistxattr twice for the same file #15207

In progress

Description

@oech3
> ls
file  file2
$ strace --trace=llistxattr ls --color=always -l .>/dev/null
llistxattr("./file", "", 4096)          = 0
llistxattr("./file2", "", 4096)         = 0
llistxattr("./file", "", 4096)          = 0
llistxattr("./file2", "", 4096)         = 0
+++ exited with 0 +++
$ strace --trace=llistxattr '/home/a/bin/gnu9.12/ls' --color=always -l .>/dev/null
llistxattr(".", "", 152)                = 0
llistxattr("file2", "", 152)            = 0
llistxattr("file", "", 152)             = 0
+++ exited with 0 +++

Activity

  1. oech3 commented on Oct 9, 2026

    @oech3
    ContributorAuthor

    @Alonely0 Do you know anything about this? because you worked about perf of ls very much.

  2. Franklin-Qi commented on Oct 9, 2026

    @Franklin-Qi
    Contributor

    -l and --color each inspected extended attributes independently, with no shared result:

    1. Long listing (-l) — has_acl() decides whether to print + after the mode bits. That lists xattrs via llistxattr. The same check ran during column-width calculation and again when printing each line.
    2. Coloring (--color) — capability styling (ca in LS_COLORS) used has_security_cap_acl(), which also listed xattrs with another llistxattr.
  3. added 3 commits that reference this issue on Oct 10, 2026
    91660d2
    bc0e5cb
    f2eb6ad
  4. Alonely0 commented on Oct 10, 2026

    @Alonely0
    Contributor
    1. @Alonely0 Do you know anything about this? because you worked about perf of ls very much.

    I have vague memories of this. It seems @Franklin-Qi already tackled it, so I'll get their PR reviewed by Monday at the latest.

  5. added 6 commits that reference this issue on Oct 12, 2026
    1e25db1
    cc5675a
    3077266
    716b3e8
    cb784bb
    733c294
  6. added a commit that references this issue on Dec 1, 2026
    f44bf3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions