[Epic 4G Android Development] SenseiSimple:
hey hoffman i know you sent me a PM, was actually working on this alongside you except my approach is different in that i only check against mount-ability once and store a propfile with the relevant details. It's safer because you don't have to keep track of the mounts. here's the relevant code, it's two parts.

The beauty about this way of doing it is that we can handle EXT4, RFS, and MTD/YAFFS2 automatically.

pmfs.sh

establishes a property listing of partition map / file system details in a file /tmp/pmfs.

#!/sbin/sh
# 2012-01-01 SENSEISIMPLE
BB="/sbin/busybox"
MOUNT="$BB mount"
UMOUNT="$BB umount"
pmfs="/tmp/pmfs"

$BB rm -f $pmfs
$BB rm -f /sdcard/.PARTMAPFS.prop

$UMOUNT /system
if $MOUNT -t ext4 /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=ext4\nsyspmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t rfs /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=rfs\nsyspmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t yaffs2 /dev/block/mtdblock2 /system &> /dev/null; then echo -e "syspm=mtd\nsysfs=yaffs2\nsyspmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /system

$UMOUNT /data
if $MOUNT -t ext4 /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=ext4\ndatpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t rfs /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=rfs\ndatpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t yaffs2 /dev/block/mtdblock3 /data &> /dev/null; then echo -e "datpm=mtd\ndatfs=yaffs2\ndatpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /data

$UMOUNT /cache
if $MOUNT -t ext4 /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=ext4\ncacpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t rfs /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=rfs\ncacpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t yaffs2 /dev/block/mtdblock4 /cache &> /dev/null; then echo -e "cacpm=mtd\ncacfs=yaffs2\ncacpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /cache

the generated file looks like this:

/tmp/pmfs (example of a consistent BML/EXT4 setup, but it could be a mix of bml: ext4/rfs. Alternately mtd: yaffs2)

syspm=bml
sysfs=ext4
syspmfs=bmlext4
datpm=bml
datfs=ext4
datpmfs=bmlext4
cacpm=bml
cacfs=ext4
cacpmfs=bmlext4

the xxxpmfs= entry is a shortcut for when you need to test the combination i.e. bmlrfs or bmlext4 instead of having to invoke 4 separate file_getprops

the updaterscript looks something like this

updater-script

package_extract_dir("tools/univ", "/tmp/tools");
set_perm_recursive(0, 0, 0777, 0777, "/tmp/tools");
run_program("/tmp/tools/pmfs.sh");

#ENSURE FILESYSTEM CONSISTENCY (i.e. make sure we don't have a mix of RFS and EXT4 partitions - have all of the same FS on partitions
ifelse(
file_getprop("/tmp/pmfs", "sysfs") == "ext4" && file_getprop("/tmp/pmfs", "datfs") == "ext4" && file_getprop("/tmp/pmfs", "cacfs") == "ext4" ||
file_getprop("/tmp/pmfs", "sysfs") == "yaffs2" && file_getprop("/tmp/pmfs", "datfs") == "yaffs2" && file_getprop("/tmp/pmfs", "cacfs") == "yaffs2" ||
file_getprop("/tmp/pmfs", "sysfs") == "rfs" && file_getprop("/tmp/pmfs", "datfs") == "rfs" && file_getprop("/tmp/pmfs", "cacfs") == "rfs",
(
ui_print("PASSED CONSISTENCY CHECK");sleep(1);
),
(
ui_print("ERROR: INCONSISTENT FILESYSTEMS");
#NEED TO REFORMAT ALL (CLEAN WIPE)
abort();
)
);

#FORMAT SYSTEM (based on what is already there) - CHECK FILE SYSTEM ext4 || rfs || yaffs2
ifelse( file_getprop("/tmp/pmfs","sysfs") == "yaffs2",
(
#format MTD/YAFFS2
format("yaffs2", "MTD", "system");
format("yaffs2", "MTD", "cache");
)
);
ifelse( file_getprop("/tmp/pmfs","sysfs") == "ext4",
(
#format ext4
run_program("/tmp/tools/fsck.ext4", "-fy", "/dev/block/stl9");
run_program("/tmp/tools/mkfs.ext4", "-O", "^ext_attr,^has_journal,^huge_file", "-L", "SYSTEM", "-b", "4096", "-m", "0", "-F", "/dev/block/stl9");
run_program("/tmp/tools/fsck.ext4", "-fy", "/dev/block/stl11");
run_program("/tmp/tools/mkfs.ext4", "-O", "^ext_attr,^has_journal,^huge_file", "-L", "SYSTEM", "-b", "4096", "-m", "0", "-F", "/dev/block/stl11");
run_program("/tmp/tools/ext4convert");
)
);
ifelse( file_getprop("/tmp/pmfs","sysfs") == "rfs",
(
#format RFS
run_program("/sbin/dd", "if=/dev/zero", "of=/dev/block/stl9", "bs=4096");
run_program("/tmp/tools/fat.format", "-F", "32", "-S", "4096", "-s", "1", "/dev/block/stl9");
run_program("/sbin/dd", "if=/dev/zero", "of=/dev/block/stl11", "bs=4096");
run_program("/tmp/tools/fat.format", "-F", "32", "-S", "4096", "-s", "1", "/dev/block/stl11");
)
);

#INSTALL KERNEL (CHECK PARTITION MAP - BML || MTD
ifelse( file_getprop("/tmp/pmfs", "syspm") == "mtd",
(
#INSTALL MTD KERNEL IMGS
assert(run_program("/tmp/tools/erase_image", "boot")); set_progress(0.270000);
assert(
package_extract_file("kernel/boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "boot"),
run_program("/tmp/tools/bml_over_mtd.sh", "boot", "72", "reservoir", "4012", "/tmp/boot.img"),
delete("/tmp/boot.img")
);
assert(run_program("/tmp/tools/erase_image", "recovery"));
assert(
package_extract_file("kernel/recovery.bin", "/tmp/recovery.img"),
run_program("/tmp/tools/bml_over_mtd.sh", "recovery", "102", "reservoir", "4012", "/tmp/recovery.img"),
delete("/tmp/recovery.img")
);
),
(
#INSTALL BML KERNEL
package_extract_file("kernel/zImage", "/tmp/zImage");
run_program("/tmp/tools/bmlwrite", "/tmp/zImage", "/dev/block/bml7");
delete("/tmp/zImage");
)
);

That is a functional example of usage right out of SleeperROM, my tools get unpacked and called from /tmp/tools , and my kernel images are kept together in the rom package