summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base/bin/mtdparts-add
blob: 805e3e29b4643ff2064691dc3ea7f3a780554d90 (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
#!/bin/sh

mkdir -p /tmp/mtdparts

parts=
device=
kernelname=

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}
        fi
done

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

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

${device}.partitions="$parts"
if [ $? != 0 ]; then
	echo "Failed to add partitions $parts to $device"
	exit 1
fi

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