Fix use-afer-free regression in RAIDZ expansion
[zfs.git] / contrib / dracut / 90zfs / zfs-generator.sh.in
blob4e1eb7490e0d69aef23eab561ca8e84341cc88da
1 #!/bin/sh
2 # shellcheck disable=SC2016,SC1004,SC2154
4 grep -wq debug /proc/cmdline && debug=1
5 [ -n "$debug" ] && echo "zfs-generator: starting" >> /dev/kmsg
7 GENERATOR_DIR="$1"
8 [ -n "$GENERATOR_DIR" ] || {
9 echo "zfs-generator: no generator directory specified, exiting" >> /dev/kmsg
10 exit 1
13 # shellcheck source=zfs-lib.sh.in
14 . /lib/dracut-zfs-lib.sh
15 decode_root_args || exit 0
17 [ -n "$debug" ] && echo "zfs-generator: writing extension for sysroot.mount to $GENERATOR_DIR/sysroot.mount.d/zfs-enhancement.conf" >> /dev/kmsg
20 mkdir -p "$GENERATOR_DIR"/sysroot.mount.d "$GENERATOR_DIR"/dracut-pre-mount.service.d
23 echo "[Unit]"
24 echo "Before=initrd-root-fs.target"
25 echo "After=zfs-import.target"
26 echo
27 echo "[Mount]"
28 echo "PassEnvironment=BOOTFS BOOTFSFLAGS"
29 echo 'What=${BOOTFS}'
30 echo "Type=zfs"
31 echo 'Options=${BOOTFSFLAGS}'
32 } > "$GENERATOR_DIR"/sysroot.mount.d/zfs-enhancement.conf
33 ln -fs ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
36 echo "[Unit]"
37 echo "After=zfs-import.target"
38 } > "$GENERATOR_DIR"/dracut-pre-mount.service.d/zfs-enhancement.conf
40 [ -n "$debug" ] && echo "zfs-generator: finished" >> /dev/kmsg
42 exit 0