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#* }"
22 # Replace plus signs and slashes with minuses;
23 # leading plus signs have special meaning in maps,
24 # and multi-component keys are just not supported.
25 _label="$(echo ${_label} | sed 's,[+/],-,g')"
34 # Print a single map entry.
43 if [ -f "/usr/local/sbin/mount.exfat" ]; then
44 echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid :/dev/${_p}"
46 /usr/bin/logger -p info -t "special_media[$$]" \
47 "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
52 if [ -f "/usr/local/bin/ntfs-3g" ]; then
53 echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid :/dev/${_p}"
55 /usr/bin/logger -p info -t "special_media[$$]" \
56 "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first"
61 echo "-fstype=${_fstype},nosuid,async :/dev/${_p}"
64 echo "-fstype=${_fstype},nosuid :/dev/${_p}"
69 # Determine map entry contents for the given key and print out the entry.
71 local _fstype _fstype_and_label _label _key _p
75 _fstype="$(fstyp "/dev/${_key}" 2> /dev/null)"
77 print_map_entry "${_fstype}" "${_key}"
81 for _p in ${providers}; do
82 _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
84 # Ignore devices for which we were unable
85 # to determine filesystem type.
89 _fstype="${_fstype_and_label%% *}"
90 if [ "${_fstype}" = "${_fstype_and_label}" ]; then
91 # No label, try another device.
95 _label="${_fstype_and_label#* }"
96 # Replace plus signs and slashes with minuses;
97 # leading plus signs have special meaning in maps,
98 # and multi-component keys are just not supported.
99 _label="$(echo ${_label} | sed 's,[+/],-,g')"
100 if [ "${_label}" != "${_key}" ]; then
101 # Labels don't match, try another device.
105 print_map_entry "${_fstype}" "${_p}"
108 # No matching device - don't print anything, autofs will handle it.
111 # Obtain a list of (geom-provider-name, access-count) pairs, turning this:
113 # z0xfffff80005085d00 [shape=hexagon,label="ada0\nr2w2e3\nerr#0\nsector=512\nstripe=0"];
119 # XXX: It would be easier to use kern.geom.conftxt instead, but it lacks
121 pairs=$(sysctl kern.geom.confdot | sed -n 's/^.*hexagon,label="\([^\]*\)\\n\([^\]*\).*/\1 \2/p')
123 # Obtain a list of GEOM providers that are not already open - not mounted,
124 # and without other GEOM class, such as gpart, attached. In other words,
125 # grep for "r0w0e0". Skip providers with names containing slashes; we're
126 # not interested in geom_label(4) creations.
127 providers=$(echo "$pairs" | awk '$2 == "r0w0e0" && $1 !~ /\// { print $1 }')
129 if [ $# -eq 0 ]; then