summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base/bin/mtdparts-add
blob: 05ab638bfcf1e39387924e05afd09972c845c731 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh

mkdir -p /tmp/mtdparts

parts=
device=
kernelname=
bbdev=

while getopt "p:d:k:b" opt; do
        if [ ${opt} = p ]; then
                parts=${OPTARG}
        elif [ ${opt} = d ]; then
                device=${OPTARG}
        elif [ ${opt} = k ]; then
                kernelname=${OPTARG}
	elif [ ${opt} = b ]; then
		bbdev=true
        fi
done

if [ -z "${device}" ]; then
	echo "$0: no device given"
	exit
fi

if [ -z "${parts}" ]; then
	echo "$0: no partitions given"
	exit
fi

if [ -e /tmp/mtdparts/${device} ]; then
	if [ -n "/dev/${device}.*.bb" ]; then
		nand -d /dev/${device}.*.bb
	fi
	delpart /dev/${device}.*
fi

addpart -n /dev/${device} "$parts" || exit
mkdir -p /tmp/mtdparts/${device}

if [ -n ${kernelname} ]; then
	global linux.mtdparts.${device}
	global.linux.mtdparts.${device}="${kernelname}:${parts}"
fi