Skip to content

shred: support character and block devices#12296

Open
gabrielhnf wants to merge 1 commit into
uutils:mainfrom
gabrielhnf:fix-shred-enospc-and-unreadable-files
Open

shred: support character and block devices#12296
gabrielhnf wants to merge 1 commit into
uutils:mainfrom
gabrielhnf:fix-shred-enospc-and-unreadable-files

Conversation

@gabrielhnf
Copy link
Copy Markdown

Fixes #12282 and #12283

shred was rejecting character and block devices with "not a file" error, and doing nothing on them even when they were valid targets. wipe_file used path.is_file() to validate the target, which returns false for all non-regular files, including devices. Additionally, the pass sequence was skipped entirely when metadata.len() == 0, which is always the case for devices.

  • Replaced path.is_file() with a check that also accepts character and block devices on Unix
  • Character devices now use a dedicated write loop that treats ENOSPC as success if no --size argument was given
  • Pass sequences are now always built for devices regardless of reported size
  • Block device size is now determined by seeking to the end of the file
  • --exact is enforced automatically for non-regular files since they have no meaningful block alignment

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

GNU testsuite comparison:

GNU test failed: tests/tail/pipe-f2. tests/tail/pipe-f2 is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/printf/printf-surprise is now passing!

@gabrielhnf gabrielhnf force-pushed the fix-shred-enospc-and-unreadable-files branch from 2e2cc85 to b0f36b7 Compare May 14, 2026 19:27
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 14, 2026

Merging this PR will degrade performance by 19.55%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 316 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory cp_recursive_deep_tree[(120, 4)] 562.5 KB 699.2 KB -19.55%

Tip

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


Comparing gabrielhnf:fix-shred-enospc-and-unreadable-files (b0f36b7) with main (6a942ba)

Open in CodSpeed

Footnotes

  1. 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.

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.

shred /dev/full should success

1 participant