blob: abaa4a9cc49e8835b494d887598db9a9910e62e8 [file] [log] [blame]
xf.li86118912025-03-19 20:07:27 -07001#!/bin/sh
2#
3#Author: comlee
4#
5
6#外部传参
7# 参数1: mount点
8# 参数2: 分区名
9RECVFS_MTD_NUM=`cat /proc/mtd | grep "$2\"" | awk '{print $1}'| cut -b 4- |sed 's/://g'`
10ubiattach /dev/ubi_ctrl -m ${RECVFS_MTD_NUM}
11echo "attach $2 $1"
12
13if [ $? != 0 ];then
14 echo "fail to attach $2"
15 exit 1
16fi
17
18UBIDEV_NUM=`ls /sys/devices/virtual/ubi|wc -l`
19MYTMP=0
20
21if [ ! -e $1 ]; then
22 mkdir -p $1
23fi
24
25while :
26do
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`
40done
41
42