5 typ
=$
(udevadm info
--query=property
--name="$1" |
sed -n 's|^ID_FS_TYPE=||p')
6 if [[ -z "$typ" ]] ; then
7 typ
=$
(blkid
-c /dev
/null
"$1" -o value
-s TYPE
)
13 # also present in 99zfssystemd
15 local poolconfigoutput
18 poolconfigtemp
="$(mktemp)"
19 if ! @sbindir@
/zpool list
-v -H -P "$1" > "$poolconfigtemp" 2>&1 ; then
20 poolconfigoutput
="$(cat "$poolconfigtemp")"
21 dinfo
"zfsexpandknowledge: pool $1 cannot be listed: $poolconfigoutput"
23 awk -F '\t' '/\t\/dev/ { print $2 }' "$poolconfigtemp" | \
24 while read -r pooldev
; do
25 if [[ -e "$pooldev" ]] ; then
26 resolved
="$(readlink -f "$pooldev")"
27 dinfo
"zfsexpandknowledge: pool $1 has device $pooldev (which resolves to $resolved)"
32 rm -f "$poolconfigtemp"
35 find_zfs_block_devices
() {
40 numfields
="$(awk '{print NF; exit}' /proc/self/mountinfo)"
41 if [[ "$numfields" = "10" ]] ; then
42 fields
="_ _ _ _ mp _ _ fstype dev _"
44 fields
="_ _ _ _ mp _ _ _ fstype dev _"
46 # shellcheck disable=SC2086
47 while read -r ${fields?} ; do
48 [[ "$fstype" = "zfs" ]] ||
continue
49 [[ "$mp" = "$1" ]] && get_pool_devices
"${dev%%/*}"
50 done < /proc
/self
/mountinfo
55 for e
in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
60 # https://github.com/dracutdevs/dracut/pull/1711 provides a zfs_devs
61 # function to detect the physical devices backing zfs pools. If this
62 # function exists in the version of dracut this module is being called
63 # from, then it does not need to run.
64 type zfs_devs
>/dev
/null
2>&1 && return 1
75 # shellcheck disable=SC2154
76 if [[ -n "$hostonly" ]]; then
92 mp
=$
(readlink
-f "$mp")
93 mountpoint
"$mp" >/dev
/null
2>&1 ||
continue
94 blockdevs
=$
(find_zfs_block_devices
"$mp")
95 if [[ -z "$blockdevs" ]] ; then continue ; fi
96 dinfo
"zfsexpandknowledge: block devices backing ZFS dataset $mp: ${blockdevs//$'\n'/ }"
99 array_contains
"$dev" "${host_devs[@]}" || host_devs
+=("$dev")
100 fstype
=$
(get_devtype
"$dev")
101 host_fs_types
["$dev"]="$fstype"
102 majmin
=$
(get_maj_min
"$dev")
103 if [[ -d "/sys/dev/block/$majmin/slaves" ]] ; then
104 for _depdev
in "/sys/dev/block/$majmin/slaves"/*; do
105 [[ -f "$_depdev/dev" ]] ||
continue
106 _depdev
="/dev/${_depdev##*/}"
107 _depdevname
=$
(udevadm info
--query=property
--name="$_depdev" |
sed -n 's|^DEVNAME=||p')
108 _depdevtype
=$
(get_devtype
"$_depdevname")
109 dinfo
"zfsexpandknowledge: underlying block device backing ZFS dataset $mp: ${_depdevname//$'\n'/ }"
110 array_contains
"$_depdevname" "${host_devs[@]}" || host_devs
+=("$_depdevname")
111 host_fs_types
["$_depdevname"]="$_depdevtype"
116 for a
in "${host_devs[@]}"
118 dinfo
"zfsexpandknowledge: host device $a"
120 for a
in "${!host_fs_types[@]}"
122 dinfo
"zfsexpandknowledge: device $a of type ${host_fs_types[$a]}"