Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Wedges enabled on -current
On Thu, 21 Aug 2014, Thomas Klausner wrote:
I have scripts that mount images via vnd + cgd. So far I have been
using fixed numbers for the vnd and cgd devices I use, making sure I
don't use them for other purposes.
Now this doesn't work any longer, because as soon as vnd is created, a
dk device takes over and the vnd cannot be used any longer (busy).
Same for the cgd. I don't see a way to make these dk* numbers fixed.
What do you propose how to do this from a script after wedges are
default?
I wrote this shell function, and use things like "$(fixpart wd0a)"
or "/dev/r$(fixpart wd0a)" instead of just "wd0a" or "/dev/rwd0a".
I would much prefer it of the old device names continued to work,
even if dk* names become available as aliases for them.
nl='
' # a newline
# convert from disklabel to wedge device names, if necessary.
# e.g. fixpart wd0a might return dk0.
fixpart()
{
local diskpart="$1" disk part
local wedgelist
local line
local IFS="${nl}"
case "${diskpart}" in
*[0-9][a-z])
disk="${diskpart%?}" # e.g. wd0a -> wd0
part="${diskpart#${disk}}" # e.g. wd0a -> a
;;
*)
# already dk*, or an unrecognised name: don't try to change it
echo "${diskpart}"
return 0
;;
esac
wedgelist="$(dkctl "$disk" listwedges)"
if [ $? = 0 ]; then
for line in ${wedgelist}; do
case "${line}" in
dk*:*/${part}|dk*:*/${part},*)
echo "${line%%:*}"
return 0
;;
esac
done
fi
# listwedges failed, or did not include the partition we want.
# just return the old-style disk and partition
echo "${disk}${part}"
return 1
}
Home |
Main Index |
Thread Index |
Old Index