-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdtools.subr
45 lines (35 loc) · 1.13 KB
/
mdtools.subr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
if [ ! "$_CBSD_MDTOOLS_SUBR" ]; then
_CBSD_MDTOOLS_SUBR=1
###
# return md device for vnode presentation by $1 file
# A=$( eval find_md_by_img /usr/jails/jails-data/image.dat )
find_md_by_img() {
local _imgpath
[ -z "${1}" ] && return 1
_imgpath=$1
/sbin/mdconfig -vl 2>/dev/null| while read _md _type _null _path; do
[ "${_path}" = "${_imgpath}" -a "${_type}" = "vnode" ] && printf ${_md##/dev/}
done
}
#return md device for vnode presentation by mountd directory
# A=$(eval find_md_by_mountpath /usr/jails/jails-data/olevole-data)
find_md_by_mountpath() {
local _mountpath _tst
[ -z "${1}" ] && return 1
_mountpath=${1}
/bin/df ${_mountpath} 2>/dev/null| tail +2 |while read _md _null _null _null _null _path; do
[ "${_path}" = "${_mountpath}" ] && printf ${_md##/dev/}
done
}
#return md device for vnode presentation by mountd directory
# A=$( eval find_path_by_md md0)
find_path_by_md() {
local _mountpath _tst
[ -z "${1}" ] && return 1
_rootmd="/dev/${1}"
/bin/df ${_mountpath} 2>/dev/null| /usr/bin/tail +2 |while read _md _null _null _null _null _path; do
[ "${_rootmd}" = "${_md}" ] && printf ${_path}
done
}
###
fi