diff --git a/automount b/automount index 0400500..2e8c9bd 100755 --- a/automount +++ b/automount @@ -265,6 +265,58 @@ __random_wait() { __log "${DEV}: random wait for '${WAIT}' seconds before 'attach' action" } +__fstype() { # 1=DEV + TYPE=$( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) + if echo "${TYPE}" | grep -q 'EXFAT' + then + TYPE=EXFAT + return + fi + TYPE='' + TYPE=$( file -r -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) + if echo "${TYPE}" | grep -q 'Unix Fast File' + then + TYPE=UFS + return + fi + if echo "${TYPE}" | grep -q 'ext2' + then + TYPE=EXT2 + return + fi + if echo "${TYPE}" | grep -q 'ext3' + then + TYPE=EXT3 + return + fi + if echo "${TYPE}" | grep -q 'ext4' + then + TYPE=EXT4 + return + fi + if echo "${TYPE}" | grep -q 'DOS/MBR boot sector' + then + TYPE=$( file -r -k -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) + if echo "${TYPE}" | grep -q 'Unix Fast File' + then + TYPE=UFS + return + fi + if echo "${TYPE}" | grep -q 'FAT' + then + TYPE=FAT + return + fi + if echo "${TYPE}" | grep -q 'NTFS' + then + TYPE=NTFS + return + fi + fi + TYPE=-1 + return +} + DEV=/dev/${1} __wait_for_boot @@ -294,8 +346,27 @@ case ${2} in OPTS="-o noatime" fi __wait_for_device ${DEV} - case $( file -k -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in - (*FAT*) # must be before NTFS section because: newfs_msdos -O NTFS -L NTFS + __fstype ${DEV} + case ${TYPE} in + (UFS) + __create_mount_point ${DEV} + __wait_for_device ${DEV} + fsck_ufs -C -y ${DEV} \ + | while read LINE + do + __log "${DEV}: fsck_ufs ${LINE}" + done + __wait_for_device ${DEV} + if mount -t ufs ${OPTS} ${DEV} ${MNT} + then + ADD=1 + else + __log "${DEV}: mount failed (ufs) 'mount -t ufs ${OPTS} ${DEV} ${MNT}'" + exit 1 + fi + __log "${DEV}: mount (ufs)" + ;; + (FAT) # must be before NTFS section because: newfs_msdos -O NTFS -L NTFS __create_mount_point ${DEV} __wait_for_device ${DEV} fsck_msdosfs -C -y ${DEV} \ @@ -314,7 +385,7 @@ case ${2} in fi __log "${DEV}: mount (fat)" ;; - (*NTFS*) # must be after FAT section: newfs_msdos -O NTFS -L NTFS + (NTFS) # must be after FAT section: newfs_msdos -O NTFS -L NTFS __create_mount_point ${DEV} __wait_for_device ${DEV} if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs @@ -348,7 +419,7 @@ case ${2} in fi __log "${DEV}: mount (ntfs)" ;; - (*ext2*) + (EXT2) __create_mount_point ${DEV} __wait_for_device ${DEV} e2fsck -y ${DEV} \ @@ -366,7 +437,7 @@ case ${2} in fi __log "${DEV}: mount (ext2)" ;; - (*ext3*) + (EXT3) __create_mount_point ${DEV} __wait_for_device ${DEV} e2fsck -y ${DEV} \ @@ -384,7 +455,7 @@ case ${2} in fi __log "${DEV}: mount (ext3)" ;; - (*ext4*) + (EXT4) __create_mount_point ${DEV} __wait_for_device ${DEV} e2fsck -y ${DEV} \ @@ -402,42 +473,21 @@ case ${2} in fi __log "${DEV}: mount (ext4)" ;; - (*Unix\ Fast\ File*) + (EXFAT) __create_mount_point ${DEV} __wait_for_device ${DEV} - fsck_ufs -C -y ${DEV} \ - | while read LINE - do - __log "${DEV}: fsck_ufs ${LINE}" - done - __wait_for_device ${DEV} - if mount -t ufs ${OPTS} ${DEV} ${MNT} + if mount.exfat ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat then ADD=1 else - __log "${DEV}: mount failed (ufs) 'mount -t ufs ${OPTS} ${DEV} ${MNT}'" + __log "${DEV}: mount failed (exfat) 'mount.exfat ${OPTS} ${DEV} ${MNT}'" exit 1 fi - __log "${DEV}: mount (ufs)" + __log "${DEV}: mount (exfat)" ;; (*) - case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in - (*EXFAT*) - __create_mount_point ${DEV} - __wait_for_device ${DEV} - if mount.exfat ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat - then - ADD=1 - else - __log "${DEV}: mount failed (exfat) 'mount.exfat ${OPTS} ${DEV} ${MNT}'" - exit 1 - fi - __log "${DEV}: mount (exfat)" - ;; - (*) - __log "${DEV}: filesystem not supported or no filesystem" - exit 0 - esac + __log "${DEV}: filesystem not supported or no filesystem" + exit 0 ;; esac if [ ${ADD} -eq 1 ] diff --git a/automount-1.5.2.tar.gz b/automount-1.5.2.tar.gz new file mode 100644 index 0000000..eab282b Binary files /dev/null and b/automount-1.5.2.tar.gz differ