Fix use-afer-free regression in RAIDZ expansion
[zfs.git] / contrib / dracut / 90zfs / zfs-env-bootfs.service.in
blobfe362b930bf5a2898e1e2dac5dab86114fecdfe0
1 [Unit]
2 Description=Set BOOTFS and BOOTFSFLAGS environment variables for dracut
3 DefaultDependencies=no
4 After=zfs-import-cache.service
5 After=zfs-import-scan.service
6 Before=zfs-import.target
8 [Service]
9 Type=oneshot
10 ExecStart=/bin/sh -c '                                                                         \
11     . /lib/dracut-zfs-lib.sh;                                                                  \
12     decode_root_args || exit 0;                                                                \
13     [ "$root" = "zfs:AUTO" ] && root="$(@sbindir@/zpool list -H -o bootfs | grep -m1 -vFx -)"; \
14     rootflags="$(getarg rootflags=)";                                                          \
15     [ "$(@sbindir@/zfs get -H -o value mountpoint "$root")" = legacy ] ||                      \
16         case ",$rootflags," in                                                                 \
17             *,zfsutil,*) ;;                                                                    \
18             ,,) rootflags=zfsutil ;;                                                           \
19             *)  rootflags="zfsutil,$rootflags" ;;                                              \
20         esac;                                                                                  \
21     exec systemctl set-environment BOOTFS="$root" BOOTFSFLAGS="$rootflags"'
23 [Install]
24 WantedBy=zfs-import.target