6 # Print newline-separated list of devices available for mounting.
7 # If there is a filesystem label - use it, otherwise use device name.
9 local _fstype _fstype_and_label _label _p
11 for _p in ${providers}; do
12 _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
14 # Ignore devices for which we were unable
15 # to determine filesystem type.
19 _fstype="${_fstype_and_label%% *}"
20 if [ "${_fstype}" != "${_fstype_and_label}" ]; then
21 _label="${_fstype_and_label#* }"
30 # Print a single map entry.
32 local _fstype _fstype_and_label _label _key _p
36 _fstype="$(fstyp "/dev/${_key}" 2> /dev/null)"
38 echo "-fstype=${_fstype},nosuid :/dev/${_key}"
42 for _p in ${providers}; do
43 _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
45 # Ignore devices for which we were unable
46 # to determine filesystem type.
50 _fstype="${_fstype_and_label%% *}"
51 if [ "${_fstype}" = "${_fstype_and_label}" ]; then
52 # No label, try another device.
56 _label="${_fstype_and_label#* }"
57 if [ "${_label}" != "${_key}" ]; then
58 # Labels don't match, try another device.
62 echo "-fstype=${_fstype},nosuid :/dev/${_p}"
65 # No matching device - don't print anything, autofs will handle it.
68 # Obtain a list of (geom-provider-name, access-count) pairs, turning this:
70 # z0xfffff80005085d00 [shape=hexagon,label="ada0\nr2w2e3\nerr#0\nsector=512\nstripe=0"];
76 # XXX: It would be easier to use kern.geom.conftxt instead, but it lacks
78 pairs=$(sysctl kern.geom.confdot | sed -n 's/^.*hexagon,label="\([^\]*\)\\n\([^\]*\).*/\1 \2/p')
80 # Obtain a list of GEOM providers that are not already open - not mounted,
81 # and without other GEOM class, such as gpart, attached. In other words,
82 # grep for "r0w0e0". Skip providers with names containing slashes; we're
83 # not interested in geom_label(4) creations.
84 providers=$(echo "$pairs" | awk '$2 == "r0w0e0" && $1 !~ /\// { print $1 }')