Skip to content

find: print special bits and no padding in -printf %m - #891

Merged
sylvestre merged 2 commits into
uutils:mainfrom
youdie006:printf-mode-special-bits
Oct 24, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
youdie006:printf-mode-special-bits

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

Part of #890.

-printf %m masked the mode with 0o777 and padded it to three digits, so a setuid binary printed 755, /tmp printed 777 and a 044 file printed 044. GNU find prints mode & 07777 in plain octal: 4755, 1777, 44. This uses {:o} of mode & 0o7777 and adds a unit test for 4755 and 044.

On a tree with setuid, setgid, sticky, 000, 044 and 7777 modes, -printf '%m %p\n' output is now identical to GNU find 4.9.0. cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test pass.

Written with AI assistance (Claude); I have reviewed the change.

Mask the mode with 0o7777 instead of 0o777 and drop the three-digit
padding, as GNU find does: 4755 is printed as 4755, 044 as 44.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 02:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (331a5c2) to head (99c9be8).
⚠️ Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #891      +/-   ##
==========================================
+ Coverage   92.27%   92.55%   +0.27%     
==========================================
  Files          35       36       +1     
  Lines        7576     7732     +156     
  Branches      393      393              
==========================================
+ Hits         6991     7156     +165     
+ Misses        443      436       -7     
+ Partials      142      140       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 15 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 20 untouched benchmarks


Comparing youdie006:printf-mode-special-bits (99c9be8) with main (531c606)

Open in CodSpeed

Comment thread src/find/matchers/printf.rs Outdated
let temp_dir = Builder::new().prefix("example").tempdir().unwrap();
let temp_dir_path = temp_dir.path().to_string_lossy();

for (mode, expected) in [(0o4755, "4755 -rwsr-xr-x"), (0o044, "44 ----r--r--")] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost the same code as test_printf_permissions just above
could you please add (0o755, "755 -rwxr-xr-x") here and remove the old test?

Review: keep one permissions test that covers 755 along with the
special-bit and short-mode cases.
@youdie006

Copy link
Copy Markdown
Contributor Author

Done: test_printf_permissions now checks 755, 4755 and 044 in one loop, and the separate special-bits test is gone.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre merged commit f00212e into uutils:main Oct 24, 2026
34 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants