Move 'local_tr' function to rc.subr and change its name to 'ltr'.

MFC after:	3 days
This commit is contained in:
Pawel Jakub Dawidek 2005-08-14 17:28:15 +00:00
parent 9405aea2e2
commit b3d1f1fce9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=149049
2 changed files with 24 additions and 22 deletions

View File

@ -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}."

View File

@ -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