Move 'local_tr' function to rc.subr and change its name to 'ltr'.
MFC after: 3 days
This commit is contained in:
parent
9405aea2e2
commit
b3d1f1fce9
@ -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}."
|
||||
|
23
etc/rc.subr
23
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
|
||||
|
Loading…
Reference in New Issue
Block a user