Skip to content

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

Open
youdie006 wants to merge 1 commit into
uutils:mainfrom
youdie006:printf-mode-special-bits
Open

youdie006 wants to merge 1 commit into
uutils:mainfrom
youdie006:printf-mode-special-bits

Conversation

@youdie006

Copy link
Copy Markdown

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.29%. Comparing base (331a5c2) to head (7c3a72c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #891      +/-   ##
==========================================
+ Coverage   92.27%   92.29%   +0.01%     
==========================================
  Files          35       35              
  Lines        7576     7591      +15     
  Branches      393      393              
==========================================
+ Hits         6991     7006      +15     
  Misses        443      443              
  Partials      142      142              

☔ 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

✅ 20 untouched benchmarks


Comparing youdie006:printf-mode-special-bits (7c3a72c) with main (331a5c2)

Open in CodSpeed

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?

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