summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base/bin/mtdparts-add
diff options
context:
space:
mode:
Diffstat (limited to 'defaultenv/defaultenv-2-base/bin/mtdparts-add')
-rw-r--r--defaultenv/defaultenv-2-base/bin/mtdparts-add49
1 files changed, 49 insertions, 0 deletions
diff --git a/defaultenv/defaultenv-2-base/bin/mtdparts-add b/defaultenv/defaultenv-2-base/bin/mtdparts-add
new file mode 100644
index 0000000..58c9fa7
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/mtdparts-add
@@ -0,0 +1,49 @@
+#!/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 "${bbdev}" ]; then
+ nand -a /dev/${device}.*
+fi
+
+if [ -n ${kernelname} ]; then
+ global linux.mtdparts.${device}
+ global.linux.mtdparts.${device}="${kernelname}:${parts}"
+fi