X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/c4ce6af0a07a0ef041fcfd09125cc0557894722d..c13b2a5d979d5c35737a0d0ed847b9ed5b0dcc27:/package/base-files/files/etc/functions.sh diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh index 1cb365d47..f757ffaf2 100755 --- a/package/base-files/files/etc/functions.sh +++ b/package/base-files/files/etc/functions.sh @@ -12,7 +12,7 @@ _C=0 NO_EXPORT=1 hotplug_dev() { - env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net + env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug-call net } append() { @@ -36,7 +36,7 @@ config () { export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1)) name="${name:-cfg$CONFIG_NUM_SECTIONS}" append CONFIG_SECTIONS "$name" - config_cb "$cfgtype" "$name" + [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name" export ${NO_EXPORT:+-n} CONFIG_SECTION="$name" export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype" } @@ -46,7 +46,7 @@ option () { local value="$*" export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value" - option_cb "$varname" "$*" + [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*" } config_rename() { @@ -120,7 +120,11 @@ config_set() { local section="$1" local option="$2" local value="$3" - export ${NO_EXPORT:+-n} "CONFIG_${section}_${option}=$value" + local old_section="$CONFIG_SECTION" + + CONFIG_SECTION="$section" + option "$option" "$value" + CONFIG_SECTION="$old_section" } config_foreach() { @@ -137,8 +141,10 @@ config_foreach() { } load_modules() { - cd /etc/modules.d - sed 's/^[^#]/insmod &/' $* | ash 2>&- || : + [ -d /etc/modules.d ] && { + cd /etc/modules.d + sed 's/^[^#]/insmod &/' $* | ash 2>&- || : + } } include() { @@ -151,9 +157,11 @@ include() { find_mtd_part() { local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" + local PREFIX=/dev/mtdblock PART="${PART##mtd}" - echo "${PART:+/dev/mtdblock/$PART}" + [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ + echo "${PART:+$PREFIX$PART}" } strtok() { # { [] ... } @@ -180,3 +188,13 @@ strtok() { # { [] ... } return $count } + + +jffs2_mark_erase() { + local part="$(find_mtd_part "$1")" + [ -z "$part" ] && { + echo Partition not found. + return 1 + } + echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1" +}