coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

tail: show end of device

Open martinkunkel2 opened this issue 6 months ago • 3 comments

gnu coreutils will show end of device for block devices. In current implementation this is skipped as a block devices are recognized as untailable.

The change ensures that we first try to output the end of any file and only then tell the observer that the file is not observable.

martinkunkel2 avatar May 30 '25 15:05 martinkunkel2

GNU testsuite comparison:

GNU test failed: tests/df/df-output. tests/df/df-output is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail/tail-sysfs. tests/tail/tail-sysfs is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/end-of-device is no longer failing!

github-actions[bot] avatar May 30 '25 15:05 github-actions[bot]

GNU testsuite comparison:

GNU test failed: tests/du/8gb. tests/du/8gb is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/tail/end-of-device is no longer failing!
Note: The gnu test tests/du/2g is now being skipped but was previously passing.

github-actions[bot] avatar May 30 '25 21:05 github-actions[bot]

GNU testsuite comparison:

GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/end-of-device is no longer failing!
Note: The gnu test tests/du/2g is now being skipped but was previously passing.

github-actions[bot] avatar May 31 '25 11:05 github-actions[bot]

GNU testsuite comparison:

GNU test failed: tests/cp/same-file. tests/cp/same-file is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/cp/sparse. tests/cp/sparse is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/cp/sparse-to-pipe. tests/cp/sparse-to-pipe is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail/truncate. tests/tail/truncate is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/end-of-device is no longer failing!

github-actions[bot] avatar Jul 06 '25 09:07 github-actions[bot]

Sorry, but you need to rebase again.

I think after this rebase, you will no longer need to change the if statement that chooses between unbounded_tail and bounded_tail.

I am in full support of moving the is_tailable check down to observer.add_path. I came to this same conclusion myself.

And if anyone asks for a unit test: I'm not sure how you would test tailing a block device. This is currently a root-only test in the GNU coreutils. The GNU test finds a mounted block device and tails it, which is generally something that only root can do.

bvinc avatar Jul 09 '25 05:07 bvinc

Sorry, but you need to rebase again.

I think after this rebase, you will no longer need to change the if statement that chooses between unbounded_tail and bounded_tail.

I am in full support of moving the is_tailable check down to observer.add_path. I came to this same conclusion myself.

And if anyone asks for a unit test: I'm not sure how you would test tailing a block device. This is currently a root-only test in the GNU coreutils. The GNU test finds a mounted block device and tails it, which is generally something that only root can do.

Thank you for the updates. I rebased and can confirm: the if statement is not required anymore.

martinkunkel2 avatar Jul 16 '25 17:07 martinkunkel2

GNU testsuite comparison:

Congrats! The gnu test tests/tail/end-of-device is no longer failing!

github-actions[bot] avatar Jul 16 '25 17:07 github-actions[bot]

I tried to add a test, see https://github.com/uutils/coreutils/commit/facc7c5d059bae8d9a9989cec9ca9cd4180cb1ae.

But the test is not very portable, e.g. on SELinux CI job, this happens:

tail: cannot open 'tmpfs' for reading: No such file or directory

I think a test is somehow pointless here. We would need to accept almost any failure as "ok".

martinkunkel2 avatar Jul 16 '25 20:07 martinkunkel2

This PR is ready from my side. Please review.

martinkunkel2 avatar Jul 16 '25 20:07 martinkunkel2

GNU testsuite comparison:

Congrats! The gnu test tests/tail/end-of-device is no longer failing!

github-actions[bot] avatar Jul 16 '25 21:07 github-actions[bot]

Congrats! The gnu test tests/tail/end-of-device is no longer failing!

Kudos and thanks!

cakebaker avatar Jul 17 '25 08:07 cakebaker