2 # Ensure that tail seeks to the end of a device
4 # Copyright (C) 2017-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 # need write access to local device
23 # (even though we don't actually write anything)
29 $BLOCKDEV -V >/dev
/null
2>&1 || BLOCKDEV
=/sbin
/blockdev
30 $BLOCKDEV --getsize64 "$1"
33 # Get path to device the current dir is on.
34 # Note df can only get fs size, not device size.
35 device
=$
(df
--output=source . |
tail -n1) || framework_failure_
37 dev_size
=$
(get_device_size
"$device") ||
38 skip_
"failed to determine size of $device"
40 tail_offset
=$
(expr $dev_size - 1023) ||
41 skip_
"failed to determine tail offset"
43 timeout
10 tail -c 1024 "$device" > end1 || fail
=1
44 timeout
10 tail -c +"$tail_offset" "$device" > end2 || fail
=1
45 test $
(wc -c < end1
) = 1024 || fail
=1
46 cmp end1 end2 || fail
=1