Newer
Older
barebox / defaultenv / defaultenv-2-base / bin / mtdparts-add
#!/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