Introduce smarter fstype() function to better determine filesystem. New automount-1.5.2.tar.gz tarball.
This commit is contained in:
parent
56316f88c8
commit
347796a242
106
automount
106
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,27 +473,7 @@ case ${2} in
|
|||
fi
|
||||
__log "${DEV}: mount (ext4)"
|
||||
;;
|
||||
(*Unix\ Fast\ File*)
|
||||
__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)"
|
||||
;;
|
||||
(*)
|
||||
case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in
|
||||
(*EXFAT*)
|
||||
(EXFAT)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
if mount.exfat ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat
|
||||
|
|
@ -437,7 +488,6 @@ case ${2} in
|
|||
(*)
|
||||
__log "${DEV}: filesystem not supported or no filesystem"
|
||||
exit 0
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
if [ ${ADD} -eq 1 ]
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue