install: allow non-directory special files as targets - #13791
Conversation
…val errors
`install /dev/null /dev/full` previously failed with:
install: invalid target '/dev/full': No such file or directory
Because the target check only accepted regular files or new file
paths, existing device files like /dev/full were rejected before the
install logic could attempt to replace them. GNU install treats such
paths as valid targets and reports the actual removal failure.
Changes:
- Add is_valid_target() which also accepts existing non-directory
entries (device files, FIFOs, sockets, symlinks) as install targets.
- Use it in standard() so special files proceed to copy_file().
- Add a Linux-only regression test for install /dev/null /dev/full.
Fixes uutils#9934
Merging this PR will degrade performance by 0.57%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | complex_relative_date |
316.1 µs | 335.4 µs | -5.75% |
| ❌ | Simulation | ls_recursive_deep_tree[(200, 2)] |
3.5 ms | 3.6 ms | -3.76% |
| ⚡ | Simulation | du_max_depth_balanced_tree[(6, 4, 10)] |
62.6 ms | 60.3 ms | +3.83% |
| ⚡ | Simulation | du_summarize_balanced_tree[(5, 4, 10)] |
16.2 ms | 15.6 ms | +3.78% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing MsfPablo:install-dev-full-error-message (8c1a009) with main (cedb4ce)
Footnotes
-
46 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. ↩
|
GNU testsuite comparison: |
| /// A valid target is a regular file, a path that can be created as a new file, | ||
| /// or any existing non-directory entry (including device files, FIFOs, sockets | ||
| /// and symlinks). Directories are handled by `copy_files_into_dir`. | ||
| fn is_valid_target(path: &Path) -> bool { |
There was a problem hiding this comment.
I'd suggest #[inline]'ing this function
install /dev/null /dev/fullcurrently fails with:GNU install treats
/dev/fullas a valid target and reports the actual failure when trying to remove/replace it:Changes:
is_valid_target()which accepts existing non-directory entries (device files, FIFOs, sockets, symlinks) in addition to regular files and new file paths.standard()so special files proceed tocopy_file()instead of being rejected as invalid targets.install /dev/null /dev/full.Fixes #9934.
🤖 This PR was generated with Claude Code.