lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | # |
| 3 | #Author: comlee |
| 4 | # |
| 5 | |
| 6 | #外部传参 |
| 7 | # 参数1: mount点 |
| 8 | # 参数2: 分区名 |
| 9 | RECVFS_MTD_NUM=`cat /proc/mtd | grep "$2\"" | awk '{print $1}'| cut -b 4- |sed 's/://g'` |
| 10 | ubiattach /dev/ubi_ctrl -m ${RECVFS_MTD_NUM} |
| 11 | echo "attach $2 $1" |
| 12 | |
| 13 | if [ $? != 0 ];then |
| 14 | echo "fail to attach $2" |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | UBIDEV_NUM=`ls /sys/devices/virtual/ubi|wc -l` |
| 19 | MYTMP=0 |
| 20 | |
| 21 | if [ ! -e $1 ]; then |
| 22 | mkdir -p $1 |
| 23 | fi |
| 24 | |
| 25 | while : |
| 26 | do |
| 27 | if [ -e /sys/devices/virtual/ubi/ubi${MYTMP} ]; then |
| 28 | TMPDEV=`cat /sys/devices/virtual/ubi/ubi${MYTMP}/mtd_num` |
| 29 | if [ $TMPDEV -eq ${RECVFS_MTD_NUM} ]; then |
| 30 | # umount $1 |
| 31 | mount -t ubifs -o rw,sync,noatime ubi${MYTMP}_0 $1 |
| 32 | exit 0 |
| 33 | fi |
| 34 | else |
| 35 | if [ ${MYTMP} -ge ${UBIDEV_NUM} ]; then |
| 36 | exit 1 |
| 37 | fi |
| 38 | fi |
| 39 | MYTMP=`expr $MYTMP + 1` |
| 40 | done |
| 41 | |
| 42 | |