summaryrefslogtreecommitdiff
path: root/recipes-core/multitech/config/config.init
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/multitech/config/config.init')
-rw-r--r--recipes-core/multitech/config/config.init36
1 files changed, 29 insertions, 7 deletions
diff --git a/recipes-core/multitech/config/config.init b/recipes-core/multitech/config/config.init
index 20080c1..fcb7f8b 100644
--- a/recipes-core/multitech/config/config.init
+++ b/recipes-core/multitech/config/config.init
@@ -41,10 +41,21 @@ mount_config() {
mkdir -p ${CONFIG_DIR}
mount ${CONFIG_DIR}
- # Prepare flash for JFFS2 if mount fails
+ # Prepare flash for JFFS2 or EXT4 if mount fails
if [ $? -ne 0 ]; then
echo "Creating ${CONFIG_DIR}"
- flash_erase -j ${CONFIG_MTDC} 0 0
+ fs=$(mount -fvn ${CONFIG_DIR})
+ if [[ $fs =~ [[:space:]]*(/dev/(...)[^[:space:]]*) ]] ; then
+ if [[ ${BASH_REMATCH[2]} == mmc ]] ; then
+ # One more check for empty
+ mdev="${BASH_REMATCH[1]}"
+ if [[ $(dd if=$mdev count=4 2>/dev/null | tr -d '\0' | wc -c) == 0 ]] ; then
+ mkfs.ext4 -O 64bit ${mdev}
+ fi
+ else
+ flash_erase -j ${CONFIG_MTDC} 0 0
+ fi
+ fi
mount ${CONFIG_DIR}
fi
}
@@ -54,10 +65,21 @@ mount_oem() {
mkdir -p ${OEM_DIR}
mount ${OEM_DIR}
- # Prepare flash for JFFS2 if mount fails
+ # Prepare flash for JFFS2 or EXT4 if mount fails
+ # Prepare flash for JFFS2 or EXT4 if mount fails
if [ $? -ne 0 ]; then
echo "Creating ${OEM_DIR}"
- flash_erase -j ${OEM_MTDC} 0 0
+ fs=$(mount -fvn ${OEM_DIR})
+ if [[ $fs =~ [[:space:]]*(/dev/(...)[^[:space:]]*) ]] ; then
+ if [[ ${BASH_REMATCH[2]} == mmc ]] ; then
+ mdev="${BASH_REMATCH[1]}"
+ if [[ $(dd if=$mdev count=4 2>/dev/null | tr -d '\0' | wc -c) == 0 ]] ; then
+ mkfs.ext4 -O 64bit ${mdev}
+ fi
+ else
+ flash_erase -j ${OEM_MTDC} 0 0
+ fi
+ fi
mount ${OEM_DIR}
fi
}
@@ -65,15 +87,15 @@ mount_oem() {
case $1 in
start)
# mount config if not already mounted
- if ! grep -q "^${CONFIG_MTDB} " /proc/mounts; then
+ if ! grep -q " ${CONFIG_DIR} " /proc/mounts; then
mount_config
else
echo "$CONFIG_DIR already mounted"
fi
# mount oem if specified in /etc/fstab and it isn't already mounted
- if grep -qE "^${OEM_MTDB}\s+${OEM_DIR}\s+" /etc/fstab; then
- if ! grep -q "^${OEM_MTDB} " /proc/mounts; then
+ if mount -fvn "${OEM_DIR}" ; then
+ if ! grep -q " ${OEM_DIR} " /proc/mounts; then
mount_oem
else
echo "$OEM_DIR already mounted"