Index: usr.sbin/autofs/autofs/special_media =================================================================== --- usr.sbin/autofs/autofs/special_media +++ usr.sbin/autofs/autofs/special_media @@ -68,7 +68,7 @@ # Determine map entry contents for the given key and print out the entry. print_one() { - local _fstype _fstype_and_label _label _key _p + local _fstype _fstype_and_label _label _key _p _first_of_p _rest_of_p _key="$1" @@ -87,6 +87,31 @@ fi _fstype="${_fstype_and_label%% *}" + + # For providers with slashes - eg "mirror/whatever" - when + # trying to access them via "/media/mirror/whatever" we will + # only get the first path component as ${_key}; we have + # to generate paths for mountpoints underneath. + case "${_p}" in + */*) + _first_of_p="${_p%%/*}" + _rest_of_p="${_p#*/}" + + if [ "${_first_of_p}" != "${_key}" ]; then + # First path component doesn't match. + continue + fi + + # Prefix the map entry with mountpoint path. + echo -n "/${_rest_of_p} " + print_map_entry "${_fstype}" "${_p}" + continue + ;; + esac + + # From this point on we're only interested in mounting + # via filesystem labels, not device names. + if [ "${_fstype}" = "${_fstype_and_label}" ]; then # No label, try another device. continue @@ -122,9 +147,8 @@ # Obtain a list of GEOM providers that are not already open - not mounted, # and without other GEOM class, such as gpart, attached. In other words, -# grep for "r0w0e0". Skip providers with names containing slashes; we're -# not interested in geom_label(4) creations. -providers=$(echo "$pairs" | awk '$2 == "r0w0e0" && $1 !~ /\// { print $1 }') +# grep for "r0w0e0". +providers=$(echo "$pairs" | awk '$2 == "r0w0e0" { print $1 }') if [ $# -eq 0 ]; then print_available