您尚未登录。

楼主 #1 2021-03-11 14:38:10

feng888
会员
注册时间: 2021-01-03
已发帖子: 59
积分: 50

自动挂载 sd卡脚本不稳定,时好时不行

自动挂载 sd卡脚本不稳定,时好时不行

#! /bin/sh

debugging message

echo "MDEV=$1 : ACTION=$2 : SUBSYSTEM=$SUBSYSTEM : DEVPATH=$DEVPATH : DEVNAME=$DEVNAME" >> /dev/console

if [ "$1" == "" ]; then
echo "parameter is none" > /tmp/error.txt
exit 1
fi

MNT=$1
#if [ $(echo $1 | grep mmcblk) ]; then

if [ $(echo $1 | grep p[25]) ]; then

MNT=sdcard2

else

MNT=sdcard

fi

#elif [ $(echo $1 | grep sd) ]; then

if [ $(echo $1 | grep p[25]) ]; then

MNT=nandcard2

else

MNT=nandcard

fi

#fi

there is no ACTION, it is for initial population

if [ "$2" = "X" ]; then
mounted=mount | grep $1 | wc -l
if [ $mounted -ge 1 ]; then

mounted, assume the ACTION is remove

#ACT=Xremove

only set add for initial population

ACT=Xadd
else

not mounted, assume the ACTION is add

ACT=Xadd
fi
else
ACT=$2
fi

if [ "$ACT" = "Xremove" ]; then

umount the device

echo "$ACT /mnt/udisk" >> /tmp/mdev.log
if ! umount -l "/mnt/udisk"; then
exit 1
else
rm -f "/mnt/udisk"
echo "[Umount FS]: /dev/$1 -X-> /mnt/udisk" > /dev/console
fi

if ! rmdir "/mnt/udisk"; then
exit 1
fi
else

mount the device

mounted=mount | grep $1 | wc -l
echo "par=$1,mounted=$mounted,MNT=$MNT" > /dev/console
if [ $mounted -ge 1 ]; then
echo "device $1 is already mounted" > /dev/console
exit 0
fi

if ! mkdir -p "/mnt/udisk"; then
echo "mkdir -p /mnt/udisk err" > /dev/console
exit 1
fi

if [ $(echo $1 | grep mtd) ]; then
if mount -t jffs2 "/dev/$1" "/mnt/udisk"; then
echo "[Mount JFFS2]: /dev/$1 --> /mnt/udisk" > /dev/console
echo "$ACT /mnt/udisk" >> /tmp/mdev.log
elif mount -t yaffs2 -o"inband-tags" "/dev/$1" "/mnt/$1"; then
echo "[Mount YAFFS2]: /dev/$1 --> /mnt/udisk" > /dev/console
echo "$ACT /mnt/$1" >> /tmp/mdev.log
elif mount -t ubifs "/dev/$1" "/mnt/udisk"; then
echo "[Mount UBIFS]: /dev/$1 --> /mnt/udisk" > /dev/console
echo "$ACT /mnt/udisk" >> /tmp/mdev.log
else

failed to mount, clean up mountpoint

echo "failed to mount, clean up mountpoint0" > /dev/console
if ! rmdir "/mnt/udisk"; then
exit 1
fi
fi
else

try vfat only

if mount -t vfat -o noatime,shortname=mixed,utf8 "/dev/$1" "/mnt/udisk"; then

ln -s /mnt/$1 /mnt/udisk

echo "[Mount VFAT]: /dev/$1 --> /mnt/udisk" > /dev/console
echo "$ACT /mnt/udisk" >> /tmp/mdev.log
else

failed to mount, clean up mountpoint

echo "failed to mount, clean up mountpoint" > /dev/console
if ! rmdir "/mnt/udisk"; then
exit 1
fi
exit 1
fi
fi
fi

MDEV=mmcblk0p1 : ACTION=Xremove : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 : DEVNAME=mmcblk0p1
[ 822.870781] mmc0: host does not support reading read-only switch, assuming write-enable
[ 822.880670] mmc0: new high speed SDHC card at address 0001
[ 822.894261] mmcblk0: mmc0:0001 00000 29.8 GiB
[ 822.907082] mmcblk0: p1
MDEV=mmcblk0 : ACTION=Xadd : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0 : DEVNAME=mmcblk0
MDEV=mmcblk0p1 : ACTION=Xadd : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 : DEVNAME=mmcblk0p1
par=mmcblk0,mounted=0,MNT=mmcblk0
par=mmcblk0p1,mounted=0,MNT=mmcblk0p1
failed to mount, clean up mountpoint
[ 823.064747] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
failed to mount, clean up mountpoint
[ 823.124543] dwmac-sun8i 1c30000.ethernet eth0: Link is Down
[ 824.164652] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[ 826.004244] mmc0: card 0001 removed
MDEV=mmcblk0 : ACTION=Xremove : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0 : DEVNAME=mmcblk0
MDEV=mmcblk0p1 : ACTION=Xremove : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 : DEVNAME=mmcblk0p1
[ 830.390786] mmc0: host does not support reading read-only switch, assuming write-enable
[ 830.400668] mmc0: new high speed SDHC card at address 0001
[ 830.407732] mmcblk0: mmc0:0001 00000 29.8 GiB
[ 830.434593] mmcblk0: p1
MDEV=mmcblk0p1 : ACTION=Xadd : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 : DEVNAME=mmcblk0p1
MDEV=mmcblk0 : ACTION=Xadd : SUBSYSTEM=block : DEVPATH=/devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0 : DEVNAME=mmcblk0
par=mmcblk0p1,mounted=0,MNT=mmcblk0p1
par=mmcblk0,mounted=0,MNT=mmcblk0
failed to mount, clean up mountpoint
failed to mount, clean up mountpoint
[ 831.444609] dwmac-sun8i 1c30000.ethernet eth0: Link is Down
[ 832.484669] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn


东莞哇酷科技有限公司开发