Debian Codegraph @

tests/ts/blkid/offset

raw
1 #!/bin/bash
2
3 # This file is part of util-linux.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 TS_TOPDIR="${0%/*}/../.."
16 TS_DESC="offset"
17
18 . "$TS_TOPDIR"/functions.sh
19 ts_init "$*"
20
21 ts_check_test_command "$TS_CMD_SFDISK"
22 ts_check_test_command "$TS_CMD_BLKID"
23 ts_check_test_command "$TS_CMD_PARTX"
24
25 ts_check_prog "mkfs.ext2"
26 ts_skip_nonroot
27
28 # set global variable TS_DEVICE
29 ts_scsi_debug_init dev_size_mb=50 sector_size=512
30
31 $TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
32 label: gpt
33 label-id: b181c399-4711-4c52-8b65-9e764541218d
34
35 ,5M,L
36 ,5M,L
37 ,5M,L
38 , ,
39 EOF
40 ts_fdisk_clean $TS_DEVICE
41 udevadm settle
42
43
44 mkfs.ext2 -b 4096 -L FOO -U ccf3dc28-f697-4577-971b-0bc79300a700 ${TS_DEVICE}2 &> /dev/null
45 udevadm settle
46 ts_device_has "TYPE" "ext2" ${TS_DEVICE}2 ||
47 ts_die "Cannot find ext2 on ${TS_DEVICE}2"
48
49 DEVNAME=$(basename $TS_DEVICE)
50 offset=$(( $(cat /sys/block/${DEVNAME}/${DEVNAME}2/start) * 512))
51 size=$(( $(cat /sys/block/${DEVNAME}/${DEVNAME}2/size) * 512))
52
53 $TS_CMD_PARTX --delete ${TS_DEVICE} &> /dev/null
54
55 $TS_CMD_BLKID --probe --output udev --offset=${offset} --size=${size} $TS_DEVICE \
56 >> $TS_OUTPUT 2>> $TS_ERRLOG
57
58 ts_finalize