X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fzpool_id%2Fzpool_id;h=bf15dc99116e393e15e5637d1b82a94ca6031764;hb=5990da81a798c087d323ba9104a6696bef2d275f;hp=e3cd0f6c0542865ef0fb5d7a2f5363b12400763c;hpb=04bf5ecc1f04ed5955ab9951c833d6b08db57356;p=zfs.git diff --git a/cmd/zpool_id/zpool_id b/cmd/zpool_id/zpool_id index e3cd0f6..bf15dc9 100755 --- a/cmd/zpool_id/zpool_id +++ b/cmd/zpool_id/zpool_id @@ -1,7 +1,6 @@ -#!/bin/bash +#!/bin/sh CONFIG="${CONFIG:-/etc/zfs/zdev.conf}" -AWK="${AWK:-/usr/bin/awk}" if [ -z "${PATH_ID}" ]; then # The path_id helper became a builtin command in udev 174. @@ -52,7 +51,7 @@ done # multipathd's naming convention) as our unique persistent key. # For traditional devices we'll obtain the key from udev's # path_id. -if [ -n "${DM_UUID}" ] && echo "${DM_UUID}" | egrep -q -e '^mpath' ; then +if [ -n "${DM_UUID}" ] && echo "${DM_UUID}" | grep -q -e '^mpath' ; then ID_PATH="dm-uuid-${DM_UUID}" else eval `${PATH_ID} ${DEVICE}` @@ -63,9 +62,19 @@ fi # configuration file which is of the format . # Lines starting with #'s are treated as comments and ignored. # Exact matches are required, wild cards are not supported, -# and only the first match is returned. Also note the following -# regex pattern only appears to work with gawk, not mawk or awk. -ID_ZPOOL=`${AWK} "/\<${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" "${CONFIG}"` +# and only the first match is returned. +ID_ZPOOL='' +while read CONFIG_ZPOOL CONFIG_PATH REPLY; do + if [ "${CONFIG_ZPOOL}" != "${CONFIG_ZPOOL#\#}" ]; then + # Skip comment lines. + continue + fi + if [ "${CONFIG_PATH}" = "${ID_PATH}" ]; then + ID_ZPOOL="${CONFIG_ZPOOL}" + break + fi +done <"${CONFIG}" + [ -z "${ID_ZPOOL}" ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}" if [ -n "${ID_ZPOOL}" ]; then