Debian Codegraph @

debian/checks/un_blkid

raw
1 #!/bin/sh
2 # this script depends on /sbin/blkid from the util-linux package
3
4 # usage: un_blkid <device> <fs_type> [<offset>]
5 # <device> may be any device that should be checked.
6 # if no <fs_type> is given, the check fails for any valid filesystem
7 # if <fs_type> is given, the check fails when a filesystem type <fs_type>
8 # is found on the device.
9
10 if test ! -x "/sbin/blkid"; then
11 echo " - WARNING: blkid from util-linux is not available, impossible to run checks."
12 exit 1
13 fi
14
15 dev="$1"
16 fs="$2"
17 offset="${3-}"
18
19 blkid="$(/sbin/blkid -o value -s TYPE -p ${offset:+-O "$offset"} -- "$dev")"
20
21 # blkid output is empty if $dev has an unknown filesystem
22 if [ -n "$blkid" ] && [ -z "$fs" ]; then
23 echo " - The device $dev contains a filesystem type $blkid${offset:+" at offset $offset"}."
24 exit 1
25 elif [ -n "$fs" ] && [ "$blkid" = "$fs" ]; then
26 echo " - The device $dev contains a filesystem type $fs${offset:+" at offset $offset"}."
27 exit 1
28 fi