mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-07-30 20:40:08 +02:00
tail: fix tailing non seekable files on certain systems
* src/tail.c (tail_bytes): On systems were blksize_t is unsigned and the same size or wider than off_t (android for example), our initialized (off_t) -1 would be promoted to unsigned before comparison, and thus fail to follow the appropriate path. * tests/tail-2/tail-c.sh: Add a test case. * NEWS: Mention the fix. This issue was introduced in commit v8.23-47-g2662702 Reported at https://github.com/termux/termux-app/issues/233
This commit is contained in:
@@ -25,6 +25,10 @@ GNU coreutils NEWS -*- outline -*-
|
||||
stty no longer crashes when processing settings with -F also specified.
|
||||
[bug introduced in fileutils-4.0]
|
||||
|
||||
tail --bytes again supports non seekable inputs on all systems.
|
||||
On systems like android it always tried to process as seekable inputs.
|
||||
[bug introduced in coreutils-8.24]
|
||||
|
||||
timeout will again notice its managed command exiting, even when
|
||||
invoked with blocked CHLD signal, or in a narrow window where
|
||||
this CHLD signal from the exiting child was missed. In each case
|
||||
|
||||
+1
-1
@@ -1855,7 +1855,7 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
|
||||
else if ((current_pos = lseek (fd, -n_bytes, SEEK_END)) != -1)
|
||||
end_pos = current_pos + n_bytes;
|
||||
}
|
||||
if (end_pos <= ST_BLKSIZE (stats))
|
||||
if (end_pos <= (off_t) ST_BLKSIZE (stats))
|
||||
return pipe_bytes (pretty_filename, fd, n_bytes, read_pos);
|
||||
if (current_pos == -1)
|
||||
current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename);
|
||||
|
||||
@@ -20,15 +20,19 @@
|
||||
print_ver_ tail
|
||||
|
||||
# Make sure it works on funny files in /proc and /sys.
|
||||
|
||||
for file in /proc/version /sys/kernel/profiling; do
|
||||
if test -r $file; then
|
||||
cp -f $file copy &&
|
||||
tail -c -1 copy > exp1 || framework_failure_
|
||||
tail -c -1 copy > exp || framework_failure_
|
||||
|
||||
tail -c -1 $file > out1 || fail=1
|
||||
compare exp1 out1 || fail=1
|
||||
tail -c -1 $file > out || fail=1
|
||||
compare exp out || fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Make sure it works for pipes
|
||||
printf '123456' | tail -c3 > out || fail=1
|
||||
printf '456' > exp || framework_failure_
|
||||
compare exp out || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
Reference in New Issue
Block a user