Add option to ignore system partitions like EFI or MSR.

This commit is contained in:
vermaden 2022-02-20 21:42:38 +01:00
parent 3dacc13068
commit 1b69cda21f
1 changed files with 28 additions and 2 deletions

View File

@ -144,6 +144,12 @@ NICENAMES (set to NO by default)
example: NICENAMES=YES example: NICENAMES=YES
IGNORE_SYS_PARTS (set to NO by default)
If set to YES automount(8) will ignore system partitions like EFI or MSR.
example: IGNORE_SYS_PARTS=YES
EOF EOF
exit 0 exit 0
} }
@ -162,7 +168,7 @@ then
echo " / / // / // // / // \\\ \ \ \\\ \ \\\ \ \\\ \ \\\ \_ " echo " / / // / // // / // \\\ \ \ \\\ \ \\\ \ \\\ \ \\\ \_ "
echo " \_____\\\____/ \__\\\____//__________\\\__\__\__\\\____/ \_____\\\__\__\\\___\ " echo " \_____\\\____/ \__\\\____//__________\\\__\__\__\\\____/ \_____\\\__\__\\\___\ "
echo echo
echo "automount 1.7.6 2021/11/15" echo "automount 1.7.7 2022/02/20"
exit 0 exit 0
fi fi
@ -202,6 +208,7 @@ fi
: ${USER="root"} # which user to use for popup : ${USER="root"} # which user to use for popup
: ${REMOVEDIRS='YES'} # remove /media dir after unmount : ${REMOVEDIRS='YES'} # remove /media dir after unmount
: ${NICENAMES='NO'} # use device label for /media dir name : ${NICENAMES='NO'} # use device label for /media dir name
: ${IGNORE_SYS_PARTS='NO'} # ignore system partitions like EFI or MSR
# init of main variables # init of main variables
DEV="/dev/${1}" DEV="/dev/${1}"
@ -422,6 +429,17 @@ case ${2} in
fi fi
__log "${DEV}: attach" __log "${DEV}: attach"
# ignore system partitions like EFI or MSR
if [ "${IGNORE_SYS_PARTS}" = 'YES' ]
then
SYS_DEV=$( echo ${1} | grep -E -o '^[a-z]+[0-9]+' )
SYS_GPART=$( gpart show -p -r ${SYS_DEV} | sed 's@=>@@g' | grep " ${1} " | awk '{print $4}' )
case ${SYS_GPART} in
(c12a7328-f81f-11d2-ba4b-00a0c93ec93b) exit 0 ;;
(e3c9e316-0b5c-4db8-817d-f92df00215ae) exit 0 ;;
esac
fi
# code for NICENAMES mounting instead of the /dev/${DEV} default # code for NICENAMES mounting instead of the /dev/${DEV} default
MNT_CANDIDATE=$( fstyp -l "/dev/${1}" 2> /dev/null | cut -d " " -f 2-99 | tr ' ' '-' ) MNT_CANDIDATE=$( fstyp -l "/dev/${1}" 2> /dev/null | cut -d " " -f 2-99 | tr ' ' '-' )
if [ "${NICENAMES}" = "YES" -a -n "${MNT_CANDIDATE}" ] if [ "${NICENAMES}" = "YES" -a -n "${MNT_CANDIDATE}" ]
@ -464,14 +482,18 @@ case ${2} in
fi fi
done done
fi fi
# check is device already mounted # check is device already mounted
__check_already_mounted "${DEV}" "${MNT}" __check_already_mounted "${DEV}" "${MNT}"
# make sure that data can be read from device # make sure that data can be read from device
__wait_for_device "${DEV}" __wait_for_device "${DEV}"
# load needed kernel modules # load needed kernel modules
kldload fusefs 1> /dev/null 2> /dev/null kldload fusefs 1> /dev/null 2> /dev/null
kldload fuse 1> /dev/null 2> /dev/null kldload fuse 1> /dev/null 2> /dev/null
kldload geom_uzip 1> /dev/null 2> /dev/null kldload geom_uzip 1> /dev/null 2> /dev/null
# detect filesysytem type # detect filesysytem type
case ${1} in case ${1} in
(iso9660*) (iso9660*)
@ -490,10 +512,12 @@ case ${2} in
FS_TYPE=${?} FS_TYPE=${?}
;; ;;
esac esac
# process ATIME option # process ATIME option
case ${ATIME} in case ${ATIME} in
([Nn][Oo]) OPTS="-o noatime" ;; ([Nn][Oo]) OPTS="-o noatime" ;;
esac esac
# filesystem options abstraction layer # filesystem options abstraction layer
case ${FS_TYPE} in case ${FS_TYPE} in
(${FS_TYPE_ISO9660}) (${FS_TYPE_ISO9660})
@ -546,7 +570,7 @@ case ${2} in
FS_MOUNT_PORT='sysutils/fusefs-hfsfuse' FS_MOUNT_PORT='sysutils/fusefs-hfsfuse'
;; ;;
(${FS_TYPE_FAT}) (${FS_TYPE_FAT})
# FreeBSD 12.x does not support '-o large' option # FreeBSD 12.x and later does not support/need '-o large' option
case $( sysctl -n kern.osrelease ) in case $( sysctl -n kern.osrelease ) in
(10*) LARGE="-o large" ;; (10*) LARGE="-o large" ;;
(11*) LARGE="-o large" ;; (11*) LARGE="-o large" ;;
@ -640,6 +664,8 @@ case ${2} in
exit 1 exit 1
fi fi
__wait_for_device "${DEV}" __wait_for_device "${DEV}"
# execute appropriate mount(8) command
COUNT=0 COUNT=0
while ! ${FS_MOUNT_CMD} ${FS_MOUNT_ARGS} 2> /dev/null while ! ${FS_MOUNT_CMD} ${FS_MOUNT_ARGS} 2> /dev/null
do do