"Fossies" - the Fresh Open Source Software Archive

Member "zfs-2.1.1/contrib/dracut/90zfs/parse-zfs.sh.in" (2 Sep 2021, 1901 Bytes) of package /linux/misc/zfs-2.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "parse-zfs.sh.in": 2.1.0-rc6_vs_2.1.0-rc7.

    1 #!/bin/sh
    2 # shellcheck disable=SC2034,SC2154
    3 
    4 . /lib/dracut-lib.sh
    5 
    6 # Let the command line override our host id.
    7 spl_hostid=$(getarg spl_hostid=)
    8 if [ -n "${spl_hostid}" ] ; then
    9     info "ZFS: Using hostid from command line: ${spl_hostid}"
   10     zgenhostid -f "${spl_hostid}"
   11 elif [ -f "/etc/hostid" ] ; then
   12     info "ZFS: Using hostid from /etc/hostid: $(hostid)"
   13 else
   14     warn "ZFS: No hostid found on kernel command line or /etc/hostid."
   15     warn "ZFS: Pools may not import correctly."
   16 fi
   17 
   18 wait_for_zfs=0
   19 case "${root}" in
   20     ""|zfs|zfs:)
   21         # We'll take root unset, root=zfs, or root=zfs:
   22         # No root set, so we want to read the bootfs attribute.  We
   23         # can't do that until udev settles so we'll set dummy values
   24         # and hope for the best later on.
   25         root="zfs:AUTO"
   26         rootok=1
   27         wait_for_zfs=1
   28 
   29         info "ZFS: Enabling autodetection of bootfs after udev settles."
   30         ;;
   31 
   32     ZFS=*|zfs:*|FILESYSTEM=*)
   33         # root is explicit ZFS root.  Parse it now.  We can handle
   34         # a root=... param in any of the following formats:
   35         # root=ZFS=rpool/ROOT
   36         # root=zfs:rpool/ROOT
   37         # root=zfs:FILESYSTEM=rpool/ROOT
   38         # root=FILESYSTEM=rpool/ROOT
   39         # root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE)
   40 
   41         # Strip down to just the pool/fs
   42         root="${root#zfs:}"
   43         root="${root#FILESYSTEM=}"
   44         root="zfs:${root#ZFS=}"
   45         # switch + with spaces because kernel cmdline does not allow us to quote parameters
   46         root=$(printf '%s\n' "$root" | sed "s/+/ /g")
   47         rootok=1
   48         wait_for_zfs=1
   49 
   50         info "ZFS: Set ${root} as bootfs."
   51         ;;
   52 esac
   53 
   54 # Make sure Dracut is happy that we have a root and will wait for ZFS
   55 # modules to settle before mounting.
   56 if [ ${wait_for_zfs} -eq 1 ]; then
   57     ln -s /dev/null /dev/root 2>/dev/null
   58     initqueuedir="${hookdir}/initqueue/finished"
   59     test -d "${initqueuedir}" || {
   60         initqueuedir="${hookdir}/initqueue-finished"
   61     }
   62     echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh"
   63 fi