From b3d1f1fce9db00424d637d7234a2e978a67b80e2 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sun, 14 Aug 2005 17:28:15 +0000 Subject: [PATCH] Move 'local_tr' function to rc.subr and change its name to 'ltr'. MFC after: 3 days --- etc/rc.d/gbde | 23 +---------------------- etc/rc.subr | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/etc/rc.d/gbde b/etc/rc.d/gbde index 612fd7e255a8..6117b86ea617 100644 --- a/etc/rc.d/gbde +++ b/etc/rc.d/gbde @@ -17,27 +17,6 @@ stop_precmd="find_gbde_devices stop" start_cmd="gbde_start" stop_cmd="gbde_stop" -# Change every ${_src} in ${_str} to ${_dst}. -# We cannot use tr(1), sed(1) nor awk(1) here, because this script is executed -# before /usr is mounted. -local_tr() -{ - _str=$1 - _src=$2 - _dst=$3 - _out="" - - IFS=${_src} - for _com in ${_str}; do - if [ -z "${_out}" ]; then - _out="${_com}" - else - _out="${_out}${_dst}${_com}" - fi - done - echo "${_out}" -} - find_gbde_devices() { case "${gbde_devices-auto}" in @@ -102,7 +81,7 @@ gbde_start() for device in $gbde_devices; do parent=${device%.bde} parent=${parent#/dev/} - parent_=`local_tr ${parent} '/' '_'` + parent_=`ltr ${parent} '/' '_'` eval "lock=\${gbde_lock_${parent_}-\"${gbde_lockdir}/${parent_}.lock\"}" if [ -e "/dev/${parent}" -a ! -e "/dev/${parent}.bde" ]; then echo "Configuring Disk Encryption for ${parent}." diff --git a/etc/rc.subr b/etc/rc.subr index 6f5c1fa79f06..77f05929b148 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1297,4 +1297,27 @@ mount_md() /sbin/mdmfs $flags -s $1 -M md $2 } +# ltr str src dst +# Change every $src in $str to $dst. +# Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor +# awk(1). +ltr() +{ + local _str _src _dst _out _com + _str=$1 + _src=$2 + _dst=$3 + _out="" + + IFS=${_src} + for _com in ${_str}; do + if [ -z "${_out}" ]; then + _out="${_com}" + else + _out="${_out}${_dst}${_com}" + fi + done + echo "${_out}" +} + fi