Skip to content

Commit 1d01973

Browse files
ps-ushankaraxboe
authored andcommitted
selftests: ublk: common: fix _get_disk_dev_t for pre-9.0 coreutils
Some distributions, such as centos stream 9, still have a version of coreutils which does not yet support the %Hr and %Lr formats for stat(1) [1, 2]. Running ublk selftests on these distributions results in the following error in tests that use the _get_disk_dev_t helper: line 23: ?r: syntax error: operand expected (error token is "?r") To better accommodate older distributions, rewrite _get_disk_dev_t to use the much older %t and %T formats for stat instead. [1] https://github.com/coreutils/coreutils/blob/v9.0/NEWS#L114 [2] https://pkgs.org/download/coreutils Signed-off-by: Uday Shankar <ushankar@purestorage.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20250423-ublk_selftests-v1-2-7d060e260e76@purestorage.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6c9c56d commit 1d01973

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/ublk/test_common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ _get_disk_dev_t() {
1717
local minor
1818

1919
dev=/dev/ublkb"${dev_id}"
20-
major=$(stat -c '%Hr' "$dev")
21-
minor=$(stat -c '%Lr' "$dev")
20+
major="0x"$(stat -c '%t' "$dev")
21+
minor="0x"$(stat -c '%T' "$dev")
2222

2323
echo $(( (major & 0xfff) << 20 | (minor & 0xfffff) ))
2424
}

0 commit comments

Comments
 (0)