Implement BLACKLIST_REGEX option. Use fusefs-lkl for all ext2/ext3/ext4 mounts. Fix exFAT detection.

This commit is contained in:
vermaden 2023-08-23 15:29:39 +02:00
parent da4bec4327
commit a7fbeeb2c7
1 changed files with 26 additions and 9 deletions

View File

@ -125,6 +125,15 @@ BLACKLIST (unset by default)
example: BLACKLIST='da0 da3s1a' example: BLACKLIST='da0 da3s1a'
BLACKLIST_REGEX (unset by default)
The boolean flag option complements the above BLACKLIST option
if one wants regex match instead of exact match for ignoring devices.
Below will ignore all partitions ada0p1/ada0p2/... of ada0 device.
example: BLACKLIST='ada0'
BLACKLIST_REGEX=true
USER (root by default) USER (root by default)
If set to some username, the mount command will If set to some username, the mount command will
chown(1) the mount directory with the user and chown(1) the mount directory with the user and
@ -259,11 +268,12 @@ __guess_fs_type() { # 1=DEV
# second time guess with file(1) tool with -k option # second time guess with file(1) tool with -k option
# (do not stop at the first match and keep going) # (do not stop at the first match and keep going)
unset FS_TYPE unset FS_TYPE
local FS_TYPE=$( file -k -r -b -L -s ${1} 2> /dev/null | sed -E 's/label:\ \".*\"//g' ) local FS_TYPE=$( file -k -r -b -L -s ${1} 2> /dev/null | tr '\n' ' ' | sed -E 's/label:\ \".*\"//g' )
case ${FS_TYPE} in case ${FS_TYPE} in
(*Unix\ Fast\ File*) return ${FS_TYPE_UFS} ;; (*Unix\ Fast\ File*) return ${FS_TYPE_UFS} ;;
(*NTFS*) return ${FS_TYPE_NTFS} ;; (*NTFS*) return ${FS_TYPE_NTFS} ;;
(*\ FAT\ *|*MSDOS*) return ${FS_TYPE_FAT} ;; (*ExFAT*) return ${FS_TYPE_EXFAT} ;;
(*\ FAT\ *|*MSDOS*) return ${FS_TYPE_FAT} ;;
esac esac
# try with fstyp(8) last (exFAT on UFS issue) # try with fstyp(8) last (exFAT on UFS issue)
unset FS_TYPE unset FS_TYPE
@ -336,7 +346,8 @@ __remove_dir() { # 1=TARGET
if [ -d "${1}" ] if [ -d "${1}" ]
then then
sleep 1 sleep 1
find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' 2> /dev/null # find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' 2> /dev/null
find "${MNT_PREFIX}" -depth 1 -empty -prune -delete 2> /dev/null
fi fi
fi fi
} }
@ -479,6 +490,10 @@ case ${2} in
then then
__log "${DEV}: device blocked by BLACKLIST option" __log "${DEV}: device blocked by BLACKLIST option"
exit 0 exit 0
elif [ -n "${BLACKLIST_REGEX}" ] && echo ${DEV} | grep -q "${I}" 1> /dev/null 2> /dev/null
then
__log "${DEV}: device blocked by BLACKLIST_REGEX option"
exit 0
fi fi
done done
fi fi
@ -536,15 +551,17 @@ case ${2} in
FS_CHECK_PORT='sysutils/e2fsprogs' FS_CHECK_PORT='sysutils/e2fsprogs'
FS_CHECK_CMD='fsck.ext2' FS_CHECK_CMD='fsck.ext2'
FS_CHECK_ARGS="-y" FS_CHECK_ARGS="-y"
FS_MOUNT_CMD='mount' FS_MOUNT_PORT='sysutils/fusefs-lkl'
FS_MOUNT_ARGS="-t ext2fs ${OPTS} ${DEV} ${MNT}" FS_MOUNT_CMD='lklfuse'
FS_MOUNT_ARGS="-o type=ext2 -o allow_other -o intr -o uid=${UID} -o gid=${GID} -o umask=002 ${DEV} ${MNT}"
;; ;;
(${FS_TYPE_EXT3}) (${FS_TYPE_EXT3})
FS_CHECK_PORT='sysutils/e2fsprogs' FS_CHECK_PORT='sysutils/e2fsprogs'
FS_CHECK_CMD='fsck.ext3' FS_CHECK_CMD='fsck.ext3'
FS_CHECK_ARGS="-y" FS_CHECK_ARGS="-y"
FS_MOUNT_CMD='mount' FS_MOUNT_PORT='sysutils/fusefs-lkl'
FS_MOUNT_ARGS="-t ext2fs ${OPTS} ${DEV} ${MNT}" FS_MOUNT_CMD='lklfuse'
FS_MOUNT_ARGS="-o type=ext3 -o allow_other -o intr -o uid=${UID} -o gid=${GID} -o umask=002 ${DEV} ${MNT}"
;; ;;
(${FS_TYPE_EXT4}) (${FS_TYPE_EXT4})
FS_CHECK_PORT='sysutils/e2fsprogs' FS_CHECK_PORT='sysutils/e2fsprogs'