diff --git a/Makefile.am b/Makefile.am index 840604c2328d..b409d2196f86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,249 +1,256 @@ ACLOCAL_AMFLAGS = -I config SUBDIRS = include if BUILD_LINUX SUBDIRS += rpm endif if CONFIG_USER SUBDIRS += etc man scripts lib tests cmd contrib if BUILD_LINUX SUBDIRS += udev endif endif if CONFIG_KERNEL SUBDIRS += module extradir = $(prefix)/src/zfs-$(VERSION) extra_HEADERS = zfs.release.in zfs_config.h.in if BUILD_LINUX kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS) endif endif AUTOMAKE_OPTIONS = foreign EXTRA_DIST = autogen.sh copy-builtin EXTRA_DIST += cppcheck-suppressions.txt EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am EXTRA_DIST += META AUTHORS COPYRIGHT LICENSE NEWS NOTICE README.md EXTRA_DIST += CODE_OF_CONDUCT.md EXTRA_DIST += module/lua/README.zfs module/os/linux/spl/README.md # Include all the extra licensing information for modules EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE.descrip EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams.descrip EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl.descrip EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2 EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2.descrip EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip @CODE_COVERAGE_RULES@ GITREV = include/zfs_gitrev.h PHONY = gitrev gitrev: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh $(GITREV) all: gitrev # Double-colon rules are allowed; there are multiple independent definitions. maintainer-clean-local:: -$(RM) $(GITREV) distclean-local:: -$(RM) -R autom4te*.cache build -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ -o -name .pc -o -name .hg -o -name .git \) -prune -o \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' -o -size 0 -o -name '*%' -o -name '.*.cmd' \ -o -name 'core' -o -name 'Makefile' -o -name 'Module.symvers' \ -o -name '*.order' -o -name '*.markers' -o -name '*.gcda' \ -o -name '*.gcno' \) \ -type f -print | xargs $(RM) all-local: -[ -x ${top_builddir}/scripts/zfs-tests.sh ] && \ ${top_builddir}/scripts/zfs-tests.sh -c dist-hook: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) $(SED) ${ac_inplace} -e 's/Release:[[:print:]]*/Release: $(RELEASE)/' \ $(distdir)/META if BUILD_LINUX # For compatibility, create a matching spl-x.y.z directly which contains # symlinks to the updated header and object file locations. These # compatibility links will be removed in the next major release. if CONFIG_KERNEL install-data-hook: rm -rf $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ mkdir $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ cd $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ ln -s ../zfs-$(VERSION)/include/spl include && \ ln -s ../zfs-$(VERSION)/$(LINUX_VERSION) $(LINUX_VERSION) && \ ln -s ../zfs-$(VERSION)/zfs_config.h.in spl_config.h.in && \ ln -s ../zfs-$(VERSION)/zfs.release.in spl.release.in && \ cd $(DESTDIR)$(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) && \ ln -fs zfs_config.h spl_config.h && \ ln -fs zfs.release spl.release endif endif PHONY += codecheck codecheck: cstyle shellcheck checkbashisms flake8 mancheck testscheck vcscheck PHONY += checkstyle checkstyle: codecheck commitcheck PHONY += commitcheck commitcheck: @if git rev-parse --git-dir > /dev/null 2>&1; then \ ${top_srcdir}/scripts/commitcheck.sh; \ fi PHONY += cstyle cstyle: @find ${top_srcdir} -name build -prune \ -o -type f -name '*.[hc]' \ ! -name 'zfs_config.*' ! -name '*.mod.c' \ ! -name 'opt_global.h' ! -name '*_if*.h' \ ! -path './module/zstd/lib/*' \ -exec ${top_srcdir}/scripts/cstyle.pl -cpP {} \+ filter_executable = -exec test -x '{}' \; -print PHONY += shellcheck shellcheck: @if type shellcheck > /dev/null 2>&1; then \ shellcheck --exclude=SC1090 --exclude=SC1117 --format=gcc \ $$(find ${top_srcdir}/scripts/*.sh -type f) \ $$(find ${top_srcdir}/cmd/zed/zed.d/*.sh -type f) \ $$(find ${top_srcdir}/cmd/zpool/zpool.d/* \ -type f ${filter_executable}); \ else \ echo "skipping shellcheck because shellcheck is not installed"; \ fi PHONY += checkbashisms checkbashisms: @if type checkbashisms > /dev/null 2>&1; then \ checkbashisms -n -p -x \ $$(find ${top_srcdir} \ -name '.git' -prune \ -o -name 'build' -prune \ -o -name 'tests' -prune \ -o -name 'config' -prune \ + -o -name 'zed-functions.sh*' -prune \ + -o -name 'zfs-import*' -prune \ + -o -name 'zfs-mount*' -prune \ + -o -name 'zfs-zed*' -prune \ + -o -name 'smart' -prune \ + -o -name 'paxcheck.sh' -prune \ + -o -name 'make_gitrev.sh' -prune \ -o -type f ! -name 'config*' \ ! -name 'libtool' \ -exec bash -c 'awk "NR==1 && /\#\!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \ else \ echo "skipping checkbashisms because checkbashisms is not installed"; \ fi PHONY += mancheck mancheck: @if type mandoc > /dev/null 2>&1; then \ find ${top_srcdir}/man/man8 -type f -name 'zfs.8' \ -o -name 'zpool.8' -o -name 'zdb.8' \ -o -name 'zgenhostid.8' | \ xargs mandoc -Tlint -Werror; \ else \ echo "skipping mancheck because mandoc is not installed"; \ fi if BUILD_LINUX stat_fmt = -c '%A %n' else stat_fmt = -f '%Sp %N' endif PHONY += testscheck testscheck: @find ${top_srcdir}/tests/zfs-tests -type f \ \( -name '*.ksh' -not ${filter_executable} \) -o \ \( -name '*.kshlib' ${filter_executable} \) -o \ \( -name '*.shlib' ${filter_executable} \) -o \ \( -name '*.cfg' ${filter_executable} \) | \ xargs -r stat ${stat_fmt} | \ awk '{c++; print} END {if(c>0) exit 1}' PHONY += vcscheck vcscheck: @if git rev-parse --git-dir > /dev/null 2>&1; then \ git ls-files . --exclude-standard --others | \ awk '{c++; print} END {if(c>0) exit 1}' ; \ fi PHONY += lint lint: cppcheck paxcheck PHONY += cppcheck cppcheck: @if type cppcheck > /dev/null 2>&1; then \ cppcheck --quiet --force --error-exitcode=2 --inline-suppr \ --suppressions-list=${top_srcdir}/cppcheck-suppressions.txt \ -UHAVE_SSE2 -UHAVE_AVX512F -UHAVE_UIO_ZEROCOPY \ ${top_srcdir}; \ else \ echo "skipping cppcheck because cppcheck is not installed"; \ fi PHONY += paxcheck paxcheck: @if type scanelf > /dev/null 2>&1; then \ ${top_srcdir}/scripts/paxcheck.sh ${top_builddir}; \ else \ echo "skipping paxcheck because scanelf is not installed"; \ fi PHONY += flake8 flake8: @if type flake8 > /dev/null 2>&1; then \ flake8 ${top_srcdir}; \ else \ echo "skipping flake8 because flake8 is not installed"; \ fi PHONY += ctags ctags: $(RM) tags find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hcS]' -print | xargs ctags -a PHONY += etags etags: $(RM) TAGS find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hcS]' -print | xargs etags -a PHONY += cscopelist cscopelist: find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hc]' -print >cscope.files PHONY += tags tags: ctags etags PHONY += pkg pkg-dkms pkg-kmod pkg-utils pkg: @DEFAULT_PACKAGE@ pkg-dkms: @DEFAULT_PACKAGE@-dkms pkg-kmod: @DEFAULT_PACKAGE@-kmod pkg-utils: @DEFAULT_PACKAGE@-utils include config/rpm.am include config/deb.am include config/tgz.am .PHONY: $(PHONY) diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id index a79aed3b5d82..8a75e638b67e 100755 --- a/cmd/vdev_id/vdev_id +++ b/cmd/vdev_id/vdev_id @@ -1,606 +1,605 @@ #!/bin/sh # # vdev_id: udev helper to generate user-friendly names for JBOD disks # # This script parses the file /etc/zfs/vdev_id.conf to map a # physical path in a storage topology to a channel name. The # channel name is combined with a disk enclosure slot number to # create an alias that reflects the physical location of the drive. # This is particularly helpful when it comes to tasks like replacing # failed drives. Slot numbers may also be re-mapped in case the # default numbering is unsatisfactory. The drive aliases will be # created as symbolic links in /dev/disk/by-vdev. # # The currently supported topologies are sas_direct and sas_switch. # A multipath mode is supported in which dm-mpath devices are # handled by examining the first-listed running component disk. In # multipath mode the configuration file should contain a channel # definition with the same name for each path to a given enclosure. # # The alias keyword provides a simple way to map already-existing # device symlinks to more convenient names. It is suitable for # small, static configurations or for sites that have some automated # way to generate the mapping file. # # # Some example configuration files are given below. # # # # Example vdev_id.conf - sas_direct. # # # # multipath no # topology sas_direct # phys_per_port 4 # slot bay # # # PCI_ID HBA PORT CHANNEL NAME # channel 85:00.0 1 A # channel 85:00.0 0 B # channel 86:00.0 1 C # channel 86:00.0 0 D # # # Custom mapping for Channel A # # # Linux Mapped # # Slot Slot Channel # slot 1 7 A # slot 2 10 A # slot 3 3 A # slot 4 6 A # # # Default mapping for B, C, and D # slot 1 4 # slot 2 2 # slot 3 1 # slot 4 3 # # # # Example vdev_id.conf - sas_switch # # # # topology sas_switch # # # SWITCH PORT CHANNEL NAME # channel 1 A # channel 2 B # channel 3 C # channel 4 D # # # # Example vdev_id.conf - multipath # # # # multipath yes # # # PCI_ID HBA PORT CHANNEL NAME # channel 85:00.0 1 A # channel 85:00.0 0 B # channel 86:00.0 1 A # channel 86:00.0 0 B # # # # Example vdev_id.conf - alias # # # # # by-vdev # # name fully qualified or base name of device link # alias d1 /dev/disk/by-id/wwn-0x5000c5002de3b9ca # alias d2 wwn-0x5000c5002def789e PATH=/bin:/sbin:/usr/bin:/usr/sbin CONFIG=/etc/zfs/vdev_id.conf PHYS_PER_PORT= DEV= MULTIPATH= TOPOLOGY= BAY= usage() { cat << EOF Usage: vdev_id [-h] vdev_id <-d device> [-c config_file] [-p phys_per_port] [-g sas_direct|sas_switch|scsi] [-m] -c specify name of an alternative config file [default=$CONFIG] -d specify basename of device (i.e. sda) -e Create enclose device symlinks only (/dev/by-enclosure) -g Storage network topology [default="$TOPOLOGY"] -m Run in multipath mode -p number of phy's per switch port [default=$PHYS_PER_PORT] -h show this summary EOF exit 0 } map_slot() { - local LINUX_SLOT=$1 - local CHANNEL=$2 - local MAPPED_SLOT= + LINUX_SLOT=$1 + CHANNEL=$2 MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \ \\$4 ~ /^${CHANNEL}$|^$/ { print \\$3; exit }" $CONFIG` if [ -z "$MAPPED_SLOT" ] ; then MAPPED_SLOT=$LINUX_SLOT fi printf "%d" ${MAPPED_SLOT} } map_channel() { - local MAPPED_CHAN= - local PCI_ID=$1 - local PORT=$2 + MAPPED_CHAN= + PCI_ID=$1 + PORT=$2 case $TOPOLOGY in "sas_switch") MAPPED_CHAN=`awk "\\$1 == \"channel\" && \\$2 == ${PORT} \ { print \\$3; exit }" $CONFIG` ;; "sas_direct"|"scsi") MAPPED_CHAN=`awk "\\$1 == \"channel\" && \ \\$2 == \"${PCI_ID}\" && \\$3 == ${PORT} \ { print \\$4; exit }" $CONFIG` ;; esac printf "%s" ${MAPPED_CHAN} } sas_handler() { if [ -z "$PHYS_PER_PORT" ] ; then PHYS_PER_PORT=`awk "\\$1 == \"phys_per_port\" \ {print \\$2; exit}" $CONFIG` fi PHYS_PER_PORT=${PHYS_PER_PORT:-4} if ! echo $PHYS_PER_PORT | grep -q -E '^[0-9]+$' ; then echo "Error: phys_per_port value $PHYS_PER_PORT is non-numeric" exit 1 fi if [ -z "$MULTIPATH_MODE" ] ; then MULTIPATH_MODE=`awk "\\$1 == \"multipath\" \ {print \\$2; exit}" $CONFIG` fi # Use first running component device if we're handling a dm-mpath device if [ "$MULTIPATH_MODE" = "yes" ] ; then # If udev didn't tell us the UUID via DM_NAME, check /dev/mapper if [ -z "$DM_NAME" ] ; then DM_NAME=`ls -l --full-time /dev/mapper | awk "/\/$DEV$/{print \\$9}"` fi # For raw disks udev exports DEVTYPE=partition when # handling partitions, and the rules can be written to # take advantage of this to append a -part suffix. For # dm devices we get DEVTYPE=disk even for partitions so # we have to append the -part suffix directly in the # helper. if [ "$DEVTYPE" != "partition" ] ; then PART=`echo $DM_NAME | awk -Fp '/p/{print "-part"$2}'` fi # Strip off partition information. DM_NAME=`echo $DM_NAME | sed 's/p[0-9][0-9]*$//'` if [ -z "$DM_NAME" ] ; then return fi # Get the raw scsi device name from multipath -ll. Strip off # leading pipe symbols to make field numbering consistent. DEV=`multipath -ll $DM_NAME | awk '/running/{gsub("^[|]"," "); print $3 ; exit}'` if [ -z "$DEV" ] ; then return fi fi if echo $DEV | grep -q ^/devices/ ; then sys_path=$DEV else sys_path=`udevadm info -q path -p /sys/block/$DEV 2>/dev/null` fi # Use positional parameters as an ad-hoc array set -- $(echo "$sys_path" | tr / ' ') num_dirs=$# scsi_host_dir="/sys" # Get path up to /sys/.../hostX i=1 while [ $i -le $num_dirs ] ; do d=$(eval echo \${$i}) scsi_host_dir="$scsi_host_dir/$d" echo $d | grep -q -E '^host[0-9]+$' && break i=$(($i + 1)) done if [ $i = $num_dirs ] ; then return fi PCI_ID=$(eval echo \${$(($i -1))} | awk -F: '{print $2":"$3}') # In sas_switch mode, the directory four levels beneath # /sys/.../hostX contains symlinks to phy devices that reveal # the switch port number. In sas_direct mode, the phy links one # directory down reveal the HBA port. port_dir=$scsi_host_dir case $TOPOLOGY in "sas_switch") j=$(($i + 4)) ;; "sas_direct") j=$(($i + 1)) ;; esac i=$(($i + 1)) while [ $i -le $j ] ; do port_dir="$port_dir/$(eval echo \${$i})" i=$(($i + 1)) done PHY=`ls -d $port_dir/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}'` if [ -z "$PHY" ] ; then PHY=0 fi PORT=$(( $PHY / $PHYS_PER_PORT )) # Look in /sys/.../sas_device/end_device-X for the bay_identifier # attribute. end_device_dir=$port_dir while [ $i -lt $num_dirs ] ; do d=$(eval echo \${$i}) end_device_dir="$end_device_dir/$d" if echo $d | grep -q '^end_device' ; then end_device_dir="$end_device_dir/sas_device/$d" break fi i=$(($i + 1)) done SLOT= case $BAY in "bay") SLOT=`cat $end_device_dir/bay_identifier 2>/dev/null` ;; "phy") SLOT=`cat $end_device_dir/phy_identifier 2>/dev/null` ;; "port") d=$(eval echo \${$i}) SLOT=`echo $d | sed -e 's/^.*://'` ;; "id") i=$(($i + 1)) d=$(eval echo \${$i}) SLOT=`echo $d | sed -e 's/^.*://'` ;; "lun") i=$(($i + 2)) d=$(eval echo \${$i}) SLOT=`echo $d | sed -e 's/^.*://'` ;; "ses") # look for this SAS path in all SCSI Enclosure Services # (SES) enclosures sas_address=`cat $end_device_dir/sas_address 2>/dev/null` enclosures=`lsscsi -g | \ sed -n -e '/enclosu/s/^.* \([^ ][^ ]*\) *$/\1/p'` for enclosure in $enclosures; do set -- $(sg_ses -p aes $enclosure | \ awk "/device slot number:/{slot=\$12} \ /SAS address: $sas_address/\ {print slot}") SLOT=$1 if [ -n "$SLOT" ] ; then break fi done ;; esac if [ -z "$SLOT" ] ; then return fi CHAN=`map_channel $PCI_ID $PORT` SLOT=`map_slot $SLOT $CHAN` if [ -z "$CHAN" ] ; then return fi echo ${CHAN}${SLOT}${PART} } scsi_handler() { if [ -z "$FIRST_BAY_NUMBER" ] ; then FIRST_BAY_NUMBER=`awk "\\$1 == \"first_bay_number\" \ {print \\$2; exit}" $CONFIG` fi FIRST_BAY_NUMBER=${FIRST_BAY_NUMBER:-0} if [ -z "$PHYS_PER_PORT" ] ; then PHYS_PER_PORT=`awk "\\$1 == \"phys_per_port\" \ {print \\$2; exit}" $CONFIG` fi PHYS_PER_PORT=${PHYS_PER_PORT:-4} if ! echo $PHYS_PER_PORT | grep -q -E '^[0-9]+$' ; then echo "Error: phys_per_port value $PHYS_PER_PORT is non-numeric" exit 1 fi if [ -z "$MULTIPATH_MODE" ] ; then MULTIPATH_MODE=`awk "\\$1 == \"multipath\" \ {print \\$2; exit}" $CONFIG` fi # Use first running component device if we're handling a dm-mpath device if [ "$MULTIPATH_MODE" = "yes" ] ; then # If udev didn't tell us the UUID via DM_NAME, check /dev/mapper if [ -z "$DM_NAME" ] ; then DM_NAME=`ls -l --full-time /dev/mapper | awk "/\/$DEV$/{print \\$9}"` fi # For raw disks udev exports DEVTYPE=partition when # handling partitions, and the rules can be written to # take advantage of this to append a -part suffix. For # dm devices we get DEVTYPE=disk even for partitions so # we have to append the -part suffix directly in the # helper. if [ "$DEVTYPE" != "partition" ] ; then PART=`echo $DM_NAME | awk -Fp '/p/{print "-part"$2}'` fi # Strip off partition information. DM_NAME=`echo $DM_NAME | sed 's/p[0-9][0-9]*$//'` if [ -z "$DM_NAME" ] ; then return fi # Get the raw scsi device name from multipath -ll. Strip off # leading pipe symbols to make field numbering consistent. DEV=`multipath -ll $DM_NAME | awk '/running/{gsub("^[|]"," "); print $3 ; exit}'` if [ -z "$DEV" ] ; then return fi fi if echo $DEV | grep -q ^/devices/ ; then sys_path=$DEV else sys_path=`udevadm info -q path -p /sys/block/$DEV 2>/dev/null` fi # expect sys_path like this, for example: # /devices/pci0000:00/0000:00:0b.0/0000:09:00.0/0000:0a:05.0/0000:0c:00.0/host3/target3:1:0/3:1:0:21/block/sdv # Use positional parameters as an ad-hoc array set -- $(echo "$sys_path" | tr / ' ') num_dirs=$# scsi_host_dir="/sys" # Get path up to /sys/.../hostX i=1 while [ $i -le $num_dirs ] ; do d=$(eval echo \${$i}) scsi_host_dir="$scsi_host_dir/$d" echo $d | grep -q -E '^host[0-9]+$' && break i=$(($i + 1)) done if [ $i = $num_dirs ] ; then return fi PCI_ID=$(eval echo \${$(($i -1))} | awk -F: '{print $2":"$3}') # In scsi mode, the directory two levels beneath # /sys/.../hostX reveals the port and slot. port_dir=$scsi_host_dir j=$(($i + 2)) i=$(($i + 1)) while [ $i -le $j ] ; do port_dir="$port_dir/$(eval echo \${$i})" i=$(($i + 1)) done set -- $(echo $port_dir | sed -e 's/^.*:\([^:]*\):\([^:]*\)$/\1 \2/') PORT=$1 SLOT=$(($2 + $FIRST_BAY_NUMBER)) if [ -z "$SLOT" ] ; then return fi CHAN=`map_channel $PCI_ID $PORT` SLOT=`map_slot $SLOT $CHAN` if [ -z "$CHAN" ] ; then return fi echo ${CHAN}${SLOT}${PART} } # Figure out the name for the enclosure symlink enclosure_handler () { # We get all the info we need from udev's DEVPATH variable: # # DEVPATH=/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/subsystem/devices/0:0:0:0/scsi_generic/sg0 # Get the enclosure ID ("0:0:0:0") ENC=$(basename $(readlink -m "/sys/$DEVPATH/../..")) if [ ! -d /sys/class/enclosure/$ENC ] ; then # Not an enclosure, bail out return fi # Get the long sysfs device path to our enclosure. Looks like: # /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/port-0:0/ ... /enclosure/0:0:0:0 ENC_DEVICE=$(readlink /sys/class/enclosure/$ENC) # Grab the full path to the hosts port dir: # /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/port-0:0 PORT_DIR=$(echo $ENC_DEVICE | grep -Eo '.+host[0-9]+/port-[0-9]+:[0-9]+') # Get the port number PORT_ID=$(echo $PORT_DIR | grep -Eo "[0-9]+$") # The PCI directory is two directories up from the port directory # /sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0 PCI_ID_LONG=$(basename $(readlink -m "/sys/$PORT_DIR/../..")) # Strip down the PCI address from 0000:05:00.0 to 05:00.0 PCI_ID=$(echo "$PCI_ID_LONG" | sed -r 's/^[0-9]+://g') # Name our device according to vdev_id.conf (like "L0" or "U1"). NAME=$(awk "/channel/{if (\$1 == \"channel\" && \$2 == \"$PCI_ID\" && \ \$3 == \"$PORT_ID\") {print \$4int(count[\$4])}; count[\$4]++}" $CONFIG) echo "${NAME}" } alias_handler () { # Special handling is needed to correctly append a -part suffix # to partitions of device mapper devices. The DEVTYPE attribute # is normally set to "disk" instead of "partition" in this case, # so the udev rules won't handle that for us as they do for # "plain" block devices. # # For example, we may have the following links for a device and its # partitions, # # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0 -> ../../dm-0 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0p1 -> ../../dm-1 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0p2 -> ../../dm-3 # # and the following alias in vdev_id.conf. # # alias A0 dm-name-isw_dibgbfcije_ARRAY0 # # The desired outcome is for the following links to be created # without having explicitly defined aliases for the partitions. # # /dev/disk/by-vdev/A0 -> ../../dm-0 # /dev/disk/by-vdev/A0-part1 -> ../../dm-1 # /dev/disk/by-vdev/A0-part2 -> ../../dm-3 # # Warning: The following grep pattern will misidentify whole-disk # devices whose names end with 'p' followed by a string of # digits as partitions, causing alias creation to fail. This # ambiguity seems unavoidable, so devices using this facility # must not use such names. - local DM_PART= + DM_PART= if echo $DM_NAME | grep -q -E 'p[0-9][0-9]*$' ; then if [ "$DEVTYPE" != "partition" ] ; then DM_PART=`echo $DM_NAME | awk -Fp '/p/{print "-part"$2}'` fi fi # DEVLINKS attribute must have been populated by already-run udev rules. for link in $DEVLINKS ; do # Remove partition information to match key of top-level device. if [ -n "$DM_PART" ] ; then link=`echo $link | sed 's/p[0-9][0-9]*$//'` fi # Check both the fully qualified and the base name of link. for l in $link `basename $link` ; do alias=`awk "\\$1 == \"alias\" && \\$3 == \"${l}\" \ { print \\$2; exit }" $CONFIG` if [ -n "$alias" ] ; then echo ${alias}${DM_PART} return fi done done } while getopts 'c:d:eg:mp:h' OPTION; do case ${OPTION} in c) CONFIG=${OPTARG} ;; d) DEV=${OPTARG} ;; e) # When udev sees a scsi_generic device, it calls this script with -e to # create the enclosure device symlinks only. We also need # "enclosure_symlinks yes" set in vdev_id.config to actually create the # symlink. ENCLOSURE_MODE=$(awk '{if ($1 == "enclosure_symlinks") print $2}' $CONFIG) if [ "$ENCLOSURE_MODE" != "yes" ] ; then exit 0 fi ;; g) TOPOLOGY=$OPTARG ;; p) PHYS_PER_PORT=${OPTARG} ;; m) MULTIPATH_MODE=yes ;; h) usage ;; esac done if [ ! -r $CONFIG ] ; then exit 0 fi -if [ -z "$DEV" -a -z "$ENCLOSURE_MODE" ] ; then +if [ -z "$DEV" ] && [ -z "$ENCLOSURE_MODE" ] ; then echo "Error: missing required option -d" exit 1 fi if [ -z "$TOPOLOGY" ] ; then TOPOLOGY=`awk "\\$1 == \"topology\" {print \\$2; exit}" $CONFIG` fi if [ -z "$BAY" ] ; then BAY=`awk "\\$1 == \"slot\" {print \\$2; exit}" $CONFIG` fi TOPOLOGY=${TOPOLOGY:-sas_direct} # Should we create /dev/by-enclosure symlinks? -if [ "$ENCLOSURE_MODE" = "yes" -a "$TOPOLOGY" = "sas_direct" ] ; then +if [ "$ENCLOSURE_MODE" = "yes" ] && [ "$TOPOLOGY" = "sas_direct" ] ; then ID_ENCLOSURE=$(enclosure_handler) if [ -z "$ID_ENCLOSURE" ] ; then exit 0 fi # Just create the symlinks to the enclosure devices and then exit. ENCLOSURE_PREFIX=$(awk '/enclosure_symlinks_prefix/{print $2}' $CONFIG) if [ -z "$ENCLOSURE_PREFIX" ] ; then ENCLOSURE_PREFIX="enc" fi echo "ID_ENCLOSURE=$ID_ENCLOSURE" echo "ID_ENCLOSURE_PATH=by-enclosure/$ENCLOSURE_PREFIX-$ID_ENCLOSURE" exit 0 fi # First check if an alias was defined for this device. ID_VDEV=`alias_handler` if [ -z "$ID_VDEV" ] ; then BAY=${BAY:-bay} case $TOPOLOGY in sas_direct|sas_switch) ID_VDEV=`sas_handler` ;; scsi) ID_VDEV=`scsi_handler` ;; *) echo "Error: unknown topology $TOPOLOGY" exit 1 ;; esac fi if [ -n "$ID_VDEV" ] ; then echo "ID_VDEV=${ID_VDEV}" echo "ID_VDEV_PATH=disk/by-vdev/${ID_VDEV}" fi diff --git a/contrib/dracut/90zfs/export-zfs.sh.in b/contrib/dracut/90zfs/export-zfs.sh.in index 892650383475..09e4a3cc0e5e 100755 --- a/contrib/dracut/90zfs/export-zfs.sh.in +++ b/contrib/dracut/90zfs/export-zfs.sh.in @@ -1,30 +1,30 @@ -#!/bin/sh +#!/bin/bash . /lib/dracut-zfs-lib.sh _do_zpool_export() { ret=0 errs="" final="${1}" info "ZFS: Exporting ZFS storage pools..." errs=$(export_all -F 2>&1) ret=$? [ -z "${errs}" ] || echo "${errs}" | vwarn if [ "x${ret}" != "x0" ]; then info "ZFS: There was a problem exporting pools." fi if [ "x${final}" != "x" ]; then info "ZFS: pool list" zpool list 2>&1 | vinfo fi return ${ret} } if command -v zpool >/dev/null; then _do_zpool_export "${1}" else : fi diff --git a/contrib/dracut/90zfs/mount-zfs.sh.in b/contrib/dracut/90zfs/mount-zfs.sh.in index 73300a9b6633..f5b3d9056c17 100755 --- a/contrib/dracut/90zfs/mount-zfs.sh.in +++ b/contrib/dracut/90zfs/mount-zfs.sh.in @@ -1,86 +1,86 @@ -#!/bin/sh +#!/bin/bash . /lib/dracut-zfs-lib.sh ZFS_DATASET="" ZFS_POOL="" case "${root}" in zfs:*) ;; *) return ;; esac GENERATOR_FILE=/run/systemd/generator/sysroot.mount GENERATOR_EXTENSION=/run/systemd/generator/sysroot.mount.d/zfs-enhancement.conf if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ] ; then # If the ZFS sysroot.mount flag exists, the initial RAM disk configured # it to mount ZFS on root. In that case, we bail early. This flag # file gets created by the zfs-generator program upon successful run. info "ZFS: There is a sysroot.mount and zfs-generator has extended it." info "ZFS: Delegating root mount to sysroot.mount." # Let us tell the initrd to run on shutdown. # We have a shutdown hook to run # because we imported the pool. # We now prevent Dracut from running this thing again. for zfsmounthook in "$hookdir"/mount/*zfs* ; do if [ -f "$zfsmounthook" ] ; then rm -f "$zfsmounthook" fi done return fi info "ZFS: No sysroot.mount exists or zfs-generator did not extend it." info "ZFS: Mounting root with the traditional mount-zfs.sh instead." # Delay until all required block devices are present. modprobe zfs 2>/dev/null udevadm settle if [ "${root}" = "zfs:AUTO" ] ; then ZFS_DATASET="$(find_bootfs)" if [ $? -ne 0 ] ; then zpool import -N -a ${ZPOOL_IMPORT_OPTS} ZFS_DATASET="$(find_bootfs)" if [ $? -ne 0 ] ; then warn "ZFS: No bootfs attribute found in importable pools." export_all -F rootok=0 return 1 fi fi info "ZFS: Using ${ZFS_DATASET} as root." fi ZFS_DATASET="${ZFS_DATASET:-${root#zfs:}}" ZFS_POOL="${ZFS_DATASET%%/*}" if import_pool "${ZFS_POOL}" ; then # Load keys if we can or if we need to if [ $(zpool list -H -o feature@encryption $(echo "${ZFS_POOL}" | awk -F\/ '{print $1}')) = 'active' ]; then # if the root dataset has encryption enabled ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${ZFS_DATASET}")" if ! [ "${ENCRYPTIONROOT}" = "-" ]; then KEYSTATUS="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")" # if the key needs to be loaded if [ "$KEYSTATUS" = "unavailable" ]; then # decrypt them ask_for_password \ --tries 5 \ --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \ --cmd "zfs load-key '${ENCRYPTIONROOT}'" fi fi fi # Let us tell the initrd to run on shutdown. # We have a shutdown hook to run # because we imported the pool. info "ZFS: Mounting dataset ${ZFS_DATASET}..." if mount_dataset "${ZFS_DATASET}" ; then ROOTFS_MOUNTED=yes return 0 fi fi rootok=0 diff --git a/contrib/dracut/90zfs/parse-zfs.sh.in b/contrib/dracut/90zfs/parse-zfs.sh.in index eccfdc6bcbd1..6a805ae24a5a 100755 --- a/contrib/dracut/90zfs/parse-zfs.sh.in +++ b/contrib/dracut/90zfs/parse-zfs.sh.in @@ -1,66 +1,66 @@ -#!/bin/sh +#!/bin/bash . /lib/dracut-lib.sh # Let the command line override our host id. spl_hostid=$(getarg spl_hostid=) if [ -n "${spl_hostid}" ] ; then info "ZFS: Using hostid from command line: ${spl_hostid}" AA=$(echo "${spl_hostid}" | cut -b 1,2) BB=$(echo "${spl_hostid}" | cut -b 3,4) CC=$(echo "${spl_hostid}" | cut -b 5,6) DD=$(echo "${spl_hostid}" | cut -b 7,8) echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" >/etc/hostid elif [ -f "/etc/hostid" ] ; then info "ZFS: Using hostid from /etc/hostid: $(hostid)" else warn "ZFS: No hostid found on kernel command line or /etc/hostid." warn "ZFS: Pools may not import correctly." fi wait_for_zfs=0 case "${root}" in ""|zfs|zfs:) # We'll take root unset, root=zfs, or root=zfs: # No root set, so we want to read the bootfs attribute. We # can't do that until udev settles so we'll set dummy values # and hope for the best later on. root="zfs:AUTO" rootok=1 wait_for_zfs=1 info "ZFS: Enabling autodetection of bootfs after udev settles." ;; ZFS\=*|zfs:*|zfs:FILESYSTEM\=*|FILESYSTEM\=*) # root is explicit ZFS root. Parse it now. We can handle # a root=... param in any of the following formats: # root=ZFS=rpool/ROOT # root=zfs:rpool/ROOT # root=zfs:FILESYSTEM=rpool/ROOT # root=FILESYSTEM=rpool/ROOT # root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE) # Strip down to just the pool/fs root="${root#zfs:}" root="${root#FILESYSTEM=}" root="zfs:${root#ZFS=}" # switch + with spaces because kernel cmdline does not allow us to quote parameters root=$(printf '%s\n' "$root" | sed "s/+/ /g") rootok=1 wait_for_zfs=1 info "ZFS: Set ${root} as bootfs." ;; esac # Make sure Dracut is happy that we have a root and will wait for ZFS # modules to settle before mounting. if [ ${wait_for_zfs} -eq 1 ]; then ln -s /dev/null /dev/root 2>/dev/null initqueuedir="${hookdir}/initqueue/finished" test -d "${initqueuedir}" || { initqueuedir="${hookdir}/initqueue-finished" } echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh" fi diff --git a/contrib/dracut/90zfs/zfs-lib.sh.in b/contrib/dracut/90zfs/zfs-lib.sh.in index 44021c6e5fc1..f470bfcc54ae 100755 --- a/contrib/dracut/90zfs/zfs-lib.sh.in +++ b/contrib/dracut/90zfs/zfs-lib.sh.in @@ -1,174 +1,174 @@ -#!/bin/sh +#!/bin/bash command -v getarg >/dev/null || . /lib/dracut-lib.sh command -v getargbool >/dev/null || { # Compatibility with older Dracut versions. # With apologies to the Dracut developers. getargbool() { if ! [ -z "$_b" ]; then unset _b fi _default="$1"; shift _b=$(getarg "$@") [ $? -ne 0 ] && [ -z "$_b" ] && _b="$_default" if [ -n "$_b" ]; then [ "$_b" = "0" ] && return 1 [ "$_b" = "no" ] && return 1 [ "$_b" = "off" ] && return 1 fi return 0 } } OLDIFS="${IFS}" NEWLINE=" " ZPOOL_IMPORT_OPTS="" if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then warn "ZFS: Will force-import pools if necessary." ZPOOL_IMPORT_OPTS="${ZPOOL_IMPORT_OPTS} -f" fi # find_bootfs # returns the first dataset with the bootfs attribute. find_bootfs() { IFS="${NEWLINE}" for dataset in $(zpool list -H -o bootfs); do case "${dataset}" in "" | "-") continue ;; "no pools available") IFS="${OLDIFS}" return 1 ;; *) IFS="${OLDIFS}" echo "${dataset}" return 0 ;; esac done IFS="${OLDIFS}" return 1 } # import_pool POOL # imports the given zfs pool if it isn't imported already. import_pool() { pool="${1}" if ! zpool list -H "${pool}" > /dev/null 2>&1; then info "ZFS: Importing pool ${pool}..." if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${pool}" ; then warn "ZFS: Unable to import pool ${pool}" return 1 fi fi return 0 } # mount_dataset DATASET # mounts the given zfs dataset. mount_dataset() { dataset="${1}" mountpoint="$(zfs get -H -o value mountpoint "${dataset}")" # We need zfsutil for non-legacy mounts and not for legacy mounts. if [ "${mountpoint}" = "legacy" ] ; then mount -t zfs "${dataset}" "${NEWROOT}" else mount -o zfsutil -t zfs "${dataset}" "${NEWROOT}" fi return $? } # export_all OPTS # exports all imported zfs pools. export_all() { opts="${@}" ret=0 IFS="${NEWLINE}" for pool in $(zpool list -H -o name) ; do if zpool list -H "${pool}" > /dev/null 2>&1; then zpool export "${pool}" ${opts} || ret=$? fi done IFS="${OLDIFS}" return ${ret} } # ask_for_password # # Wraps around plymouth ask-for-password and adds fallback to tty password ask # if plymouth is not present. # # --cmd command # Command to execute. Required. # --prompt prompt # Password prompt. Note that function already adds ':' at the end. # Recommended. # --tries n # How many times repeat command on its failure. Default is 3. # --ply-[cmd|prompt|tries] # Command/prompt/tries specific for plymouth password ask only. # --tty-[cmd|prompt|tries] # Command/prompt/tries specific for tty password ask only. # --tty-echo-off # Turn off input echo before tty command is executed and turn on after. # It's useful when password is read from stdin. ask_for_password() { ply_tries=3 tty_tries=3 while [ "$#" -gt 0 ]; do case "$1" in --cmd) ply_cmd="$2"; tty_cmd="$2"; shift;; --ply-cmd) ply_cmd="$2"; shift;; --tty-cmd) tty_cmd="$2"; shift;; --prompt) ply_prompt="$2"; tty_prompt="$2"; shift;; --ply-prompt) ply_prompt="$2"; shift;; --tty-prompt) tty_prompt="$2"; shift;; --tries) ply_tries="$2"; tty_tries="$2"; shift;; --ply-tries) ply_tries="$2"; shift;; --tty-tries) tty_tries="$2"; shift;; --tty-echo-off) tty_echo_off=yes;; esac shift done { flock -s 9; # Prompt for password with plymouth, if installed and running. if type plymouth >/dev/null 2>&1 && plymouth --ping 2>/dev/null; then plymouth ask-for-password \ --prompt "$ply_prompt" --number-of-tries="$ply_tries" \ --command="$ply_cmd" ret=$? else if [ "$tty_echo_off" = yes ]; then stty_orig="$(stty -g)" stty -echo fi i=1 while [ "$i" -le "$tty_tries" ]; do [ -n "$tty_prompt" ] && \ printf "%s [%i/%i]:" "$tty_prompt" "$i" "$tty_tries" >&2 eval "$tty_cmd" && ret=0 && break ret=$? i=$((i+1)) [ -n "$tty_prompt" ] && printf '\n' >&2 done unset i [ "$tty_echo_off" = yes ] && stty "$stty_orig" fi } 9>/.console_lock [ $ret -ne 0 ] && echo "Wrong password" >&2 return $ret } diff --git a/contrib/dracut/90zfs/zfs-load-key.sh.in b/contrib/dracut/90zfs/zfs-load-key.sh.in index 85e55c51bfa4..ff586ef654b8 100755 --- a/contrib/dracut/90zfs/zfs-load-key.sh.in +++ b/contrib/dracut/90zfs/zfs-load-key.sh.in @@ -1,58 +1,58 @@ -#!/bin/sh +#!/bin/bash # only run this on systemd systems, we handle the decrypt in mount-zfs.sh in the mount hook otherwise [ -e /bin/systemctl ] || return 0 # This script only gets executed on systemd systems, see mount-zfs.sh for non-systemd systems # import the libs now that we know the pool imported [ -f /lib/dracut-lib.sh ] && dracutlib=/lib/dracut-lib.sh [ -f /usr/lib/dracut/modules.d/99base/dracut-lib.sh ] && dracutlib=/usr/lib/dracut/modules.d/99base/dracut-lib.sh # shellcheck source=./lib-zfs.sh.in . "$dracutlib" # load the kernel command line vars [ -z "$root" ] && root="$(getarg root=)" # If root is not ZFS= or zfs: or rootfstype is not zfs then we are not supposed to handle it. [ "${root##zfs:}" = "${root}" ] && [ "${root##ZFS=}" = "${root}" ] && [ "$rootfstype" != "zfs" ] && exit 0 # There is a race between the zpool import and the pre-mount hooks, so we wait for a pool to be imported while true; do zpool list -H | grep -q -v '^$' && break [ "$(systemctl is-failed zfs-import-cache.service)" = 'failed' ] && exit 1 [ "$(systemctl is-failed zfs-import-scan.service)" = 'failed' ] && exit 1 sleep 0.1s done # run this after import as zfs-import-cache/scan service is confirmed good # we do not overwrite the ${root} variable, but create a new one, BOOTFS, to hold the dataset if [ "${root}" = "zfs:AUTO" ] ; then BOOTFS="$(zpool list -H -o bootfs | awk '$1 != "-" {print; exit}')" else BOOTFS="${root##zfs:}" BOOTFS="${BOOTFS##ZFS=}" fi # if pool encryption is active and the zfs command understands '-o encryption' if [ "$(zpool list -H -o feature@encryption $(echo "${BOOTFS}" | awk -F\/ '{print $1}'))" = 'active' ]; then # if the root dataset has encryption enabled ENCRYPTIONROOT=$(zfs get -H -o value encryptionroot "${BOOTFS}") # where the key is stored (in a file or loaded via prompt) KEYLOCATION=$(zfs get -H -o value keylocation "${ENCRYPTIONROOT}") if ! [ "${ENCRYPTIONROOT}" = "-" ]; then KEYSTATUS="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")" # continue only if the key needs to be loaded [ "$KEYSTATUS" = "unavailable" ] || exit 0 # if key is stored in a file, do not prompt if ! [ "${KEYLOCATION}" = "prompt" ]; then zfs load-key "${ENCRYPTIONROOT}" else # decrypt them TRY_COUNT=5 while [ $TRY_COUNT -gt 0 ]; do systemd-ask-password "Encrypted ZFS password for ${BOOTFS}" --no-tty | zfs load-key "${ENCRYPTIONROOT}" && break TRY_COUNT=$((TRY_COUNT - 1)) done fi fi fi diff --git a/contrib/dracut/90zfs/zfs-needshutdown.sh.in b/contrib/dracut/90zfs/zfs-needshutdown.sh.in index e3d1b59ccac9..ddd3edae0014 100755 --- a/contrib/dracut/90zfs/zfs-needshutdown.sh.in +++ b/contrib/dracut/90zfs/zfs-needshutdown.sh.in @@ -1,10 +1,10 @@ -#!/bin/sh +#!/bin/bash type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh if zpool list 2>&1 | grep -q 'no pools available' ; then info "ZFS: No active pools, no need to export anything." else info "ZFS: There is an active pool, will export it." need_shutdown fi diff --git a/contrib/initramfs/zfsunlock b/contrib/initramfs/zfsunlock index f6b6b9dbe14d..cf8e45249024 100755 --- a/contrib/initramfs/zfsunlock +++ b/contrib/initramfs/zfsunlock @@ -1,42 +1,42 @@ #!/bin/sh set -eu if [ ! -e /run/zfs_fs_name ]; then echo "Wait for the root pool to be imported or press Ctrl-C to exit." fi while [ ! -e /run/zfs_fs_name ]; do if [ -e /run/zfs_unlock_complete ]; then exit 0 fi - sleep 0.5 + sleep 1 done echo echo "Unlocking encrypted ZFS filesystems..." echo "Enter the password or press Ctrl-C to exit." echo zfs_fs_name="" if [ ! -e /run/zfs_unlock_complete_notify ]; then mkfifo /run/zfs_unlock_complete_notify fi while [ ! -e /run/zfs_unlock_complete ]; do zfs_fs_name=$(cat /run/zfs_fs_name) zfs_console_askpwd_cmd=$(cat /run/zfs_console_askpwd_cmd) systemd-ask-password "Encrypted ZFS password for ${zfs_fs_name}:" | \ /sbin/zfs load-key "$zfs_fs_name" || true if [ "$(/sbin/zfs get -H -ovalue keystatus "$zfs_fs_name" 2> /dev/null)" = "available" ]; then echo "Password for $zfs_fs_name accepted." zfs_console_askpwd_pid=$(ps | awk '!'"/awk/ && /$zfs_console_askpwd_cmd/ { print \$1; exit }") if [ -n "$zfs_console_askpwd_pid" ]; then kill "$zfs_console_askpwd_pid" fi # Wait for another filesystem to unlock. while [ "$(cat /run/zfs_fs_name)" = "$zfs_fs_name" ] && [ ! -e /run/zfs_unlock_complete ]; do - sleep 0.5 + sleep 1 done else echo "Wrong password. Try again." fi done echo "Unlocking complete. Resuming boot sequence..." echo "Please reconnect in a while." echo "ok" > /run/zfs_unlock_complete_notify diff --git a/scripts/dkms.mkconf b/scripts/dkms.mkconf index 8c555597335e..28d9609f721b 100755 --- a/scripts/dkms.mkconf +++ b/scripts/dkms.mkconf @@ -1,120 +1,120 @@ #!/bin/sh PROG=$0 pkgcfg=/etc/sysconfig/zfs while getopts "n:v:c:f:" opt; do case $opt in n) pkgname=$OPTARG ;; v) pkgver=$OPTARG ;; c) pkgcfg=$OPTARG ;; f) filename=$OPTARG ;; esac done -if [ -z "${pkgname}" -o -z "${pkgver}" -o -z "${filename}" ]; then +if [ -z "${pkgname}" ] || [ -z "${pkgver}" ] || [ -z "${filename}" ]; then echo "Usage: $PROG -n -v -c -f " exit 1 fi cat >${filename} < -k -n " \ "-t -v " exit 1 fi cp "${tree}/${pkgname}/${pkgver}/build/zfs_config.h" \ "${tree}/${pkgname}/${pkgver}/build/module/Module.symvers" \ "${tree}/${pkgname}/${pkgver}/${kver}/${arch}/"