Skip to content

uucore: build safe_traversal on AIX and Hurd - #15030

Merged
sylvestre merged 1 commit into
uutils:mainfrom
abendrothj:safe-traversal-aix-hurd
Oct 7, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
abendrothj:safe-traversal-aix-hurd

Conversation

@abendrothj

@abendrothj abendrothj commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Map the timespec time fields for AIX and Hurd inside the existing MetadataExt accessors, and gate safe_traversal and its users on Redox only, where nix has none of the *at calls.

With AIX on the safe_traversal path, chmod's AIX-only path-based symlink handling is no longer used and is removed: handle_symlink_during_traversal and its wrapper handle_symlink_during_recursion. If safe_traversal can't be brought to some other platform later, they are in this commit to restore from. The target-specific safe-traversal features of chmod, chown and install are also dropped, since perms already enables it.

Cross-checked with -Zbuild-std clippy for x86_64-unknown-hurd-gnu and i686-unknown-hurd-gnu; not run on Hurd. AIX (powerpc64-ibm-aix) doesn't build with libc 0.2.190 on main either (#15083); with libc pinned to 0.2.189 locally, uucore's safe_traversal builds. uu_du still fails to build on Hurd in fsext, as it does on main.

Closes #15028

Copilot AI balanced review requested due to automatic review settings October 2, 2026 08:08

Copilot AI left a comment

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.

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

@codspeed

codspeed Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 21.4%

⚡ 3 improved benchmarks
❌ 1 regressed benchmark
✅ 393 untouched benchmarks
🆕 2 new benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation three_39_bit_primes 228.6 ms 694.2 ms -67.07%
⚡ Simulation thirteen_39_bit_primes 9.2 s 8.7 s +6.1%
⚡ Simulation du_wide_tree[(5000, 500)] 15.9 ms 15.2 ms +4.7%
⚡ Simulation tr_single_char_replace 14.5 ms 13.9 ms +4.36%
🆕 Memory tr_delete_single_char N/A 35.4 KB N/A
🆕 Simulation tr_delete_single_char N/A 103.9 ms N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing abendrothj:safe-traversal-aix-hurd (85d3e76) with main (968853a)2

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (ded92e1) during the generation of this report, so 968853a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)

Comment thread src/uu/chown/Cargo.toml Outdated

[target.'cfg(all(unix, not(any(target_os = "aix", target_os = "hurd", target_os = "redox"))))'.dependencies]
[target.'cfg(all(unix, not(target_os = "redox")))'.dependencies]
uucore = { workspace = true, features = ["safe-traversal"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks like the safe-traversal feature is unnecessary for chown

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, perms already pulls it in. Dropped it from chown, and from chmod and install too, which had the same redundant section.

@abendrothj
abendrothj force-pushed the safe-traversal-aix-hurd branch from 55e7c4c to 0df23c8 Compare October 2, 2026 20:12
Copilot AI balanced review requested due to automatic review settings October 2, 2026 20:12

Copilot AI left a comment

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.

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

@xtqqczze

xtqqczze commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Please note the removal of the fallback path handle_symlink_during_traversal in the description, in case we ever need it to implement safe_traversal for additional platforms.

@abendrothj

Copy link
Copy Markdown
Contributor Author

Added to the description.


// aix and hurd only expose the times as `timespec` fields (`st_atim` and
// so on), whose types vary between them and with the pointer width.
#[cfg(any(target_os = "aix", target_os = "hurd"))]

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 function 6 times plus 6 not(any(aix, hurd)) gates on the existing ones. could you please add an aix/hurd branch inside the existing fns instead, like netbsd does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: the six extra functions and the not(any(aix, hurd)) gates are gone; AIX and Hurd are a branch inside the existing MetadataExt accessors, as for NetBSD.

// aix and hurd only expose the times as `timespec` fields (`st_atim` and
// so on), whose types vary between them and with the pointer width.
#[cfg(any(target_os = "aix", target_os = "hurd"))]
#[allow(clippy::unnecessary_cast)]

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.

the fields are all i32/i64 here, so .into() should work and we can drop the 6 #[allow(clippy::unnecessary_cast)], no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The allows are gone, but I used as _ instead of .into(). On x86_64 Hurd the fields are already i64, so .into() gives six useless_conversion errors there (i686 Hurd was fine). as _ is clean under clippy -D warnings for x86_64 Hurd.

@xtqqczze

xtqqczze commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

sorry, compilation on AIX targets is blocked on #15083

The only thing keeping it off them was the stat time fields, which they
expose as timespecs (st_atim and so on). Read those there, and gate
safe_traversal and its users on Redox alone, so chmod, du, install and
rm walk trees through descriptors there too. The path-based chmod
helpers that only AIX still used are gone, as are the target-specific
safe-traversal features of chmod, chown and install, which already get
it through perms.

Redox stays excluded: nix has none of the *at calls there.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:15
@abendrothj
abendrothj force-pushed the safe-traversal-aix-hurd branch from 0df23c8 to 85d3e76 Compare October 6, 2026 07:15

Copilot AI left a comment

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.

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

@abendrothj

Copy link
Copy Markdown
Contributor Author

Yes, with libc 0.2.190 nix fails in statvfs.rs (fsid_t vs u64) before it reaches uucore, on main as well as here. With libc pinned to 0.2.189 locally, uucore's safe_traversal builds for AIX; I left the lockfile as it is on main. I'd keep AIX in, since it shares the code with Hurd and lets chmod drop its AIX-only path, so it builds once #15083 is sorted out. I can make this Hurd-only if you'd prefer.

@sylvestre
sylvestre merged commit 4e2be1c into uutils:main Oct 7, 2026
191 of 192 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.

uucore: safe_traversal is not built on AIX and Hurd

4 participants