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
116
automount
116
automount
|
|
@ -265,6 +265,58 @@ __random_wait() {
|
||||||
__log "${DEV}: random wait for '${WAIT}' seconds before 'attach' action"
|
__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}
|
DEV=/dev/${1}
|
||||||
|
|
||||||
__wait_for_boot
|
__wait_for_boot
|
||||||
|
|
@ -294,8 +346,27 @@ case ${2} in
|
||||||
OPTS="-o noatime"
|
OPTS="-o noatime"
|
||||||
fi
|
fi
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
case $( file -k -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
|
__fstype ${DEV}
|
||||||
(*FAT*) # must be before NTFS section because: newfs_msdos -O NTFS -L NTFS
|
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}
|
__create_mount_point ${DEV}
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
fsck_msdosfs -C -y ${DEV} \
|
fsck_msdosfs -C -y ${DEV} \
|
||||||
|
|
@ -314,7 +385,7 @@ case ${2} in
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (fat)"
|
__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}
|
__create_mount_point ${DEV}
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs
|
if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs
|
||||||
|
|
@ -348,7 +419,7 @@ case ${2} in
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (ntfs)"
|
__log "${DEV}: mount (ntfs)"
|
||||||
;;
|
;;
|
||||||
(*ext2*)
|
(EXT2)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
e2fsck -y ${DEV} \
|
e2fsck -y ${DEV} \
|
||||||
|
|
@ -366,7 +437,7 @@ case ${2} in
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (ext2)"
|
__log "${DEV}: mount (ext2)"
|
||||||
;;
|
;;
|
||||||
(*ext3*)
|
(EXT3)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
e2fsck -y ${DEV} \
|
e2fsck -y ${DEV} \
|
||||||
|
|
@ -384,7 +455,7 @@ case ${2} in
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (ext3)"
|
__log "${DEV}: mount (ext3)"
|
||||||
;;
|
;;
|
||||||
(*ext4*)
|
(EXT4)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
e2fsck -y ${DEV} \
|
e2fsck -y ${DEV} \
|
||||||
|
|
@ -402,42 +473,21 @@ case ${2} in
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (ext4)"
|
__log "${DEV}: mount (ext4)"
|
||||||
;;
|
;;
|
||||||
(*Unix\ Fast\ File*)
|
(EXFAT)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
__wait_for_device ${DEV}
|
__wait_for_device ${DEV}
|
||||||
fsck_ufs -C -y ${DEV} \
|
if mount.exfat ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat
|
||||||
| while read LINE
|
|
||||||
do
|
|
||||||
__log "${DEV}: fsck_ufs ${LINE}"
|
|
||||||
done
|
|
||||||
__wait_for_device ${DEV}
|
|
||||||
if mount -t ufs ${OPTS} ${DEV} ${MNT}
|
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
else
|
else
|
||||||
__log "${DEV}: mount failed (ufs) 'mount -t ufs ${OPTS} ${DEV} ${MNT}'"
|
__log "${DEV}: mount failed (exfat) 'mount.exfat ${OPTS} ${DEV} ${MNT}'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (ufs)"
|
__log "${DEV}: mount (exfat)"
|
||||||
;;
|
;;
|
||||||
(*)
|
(*)
|
||||||
case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in
|
__log "${DEV}: filesystem not supported or no filesystem"
|
||||||
(*EXFAT*)
|
exit 0
|
||||||
__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
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [ ${ADD} -eq 1 ]
|
if [ ${ADD} -eq 1 ]
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue