#!/bin/sh # load needed modules modprobe nandsim first_id_byte=0x2c second_id_byte=0xa1 third_id_byte=0x80 fourth_id_byte=0x15 parts=128 modprobe mtdblock # generate some arbitrary data dd if=/dev/urandom of=rnd bs=2048 count=64 # clean and mount simulated NAND partition flash_erase /dev/mtd0 0 0 mkdir -p mnt_jffs2 mount -t jffs2 /dev/mtdblock0 mnt_jffs2 # set up a critical node structure cd mnt_jffs2 mkdir tmpdir cp ../rnd DELETE1 cp ../rnd DELETE2 cp ../rnd KEEP1 mkdir tmpdir/subdir cp ../rnd KEEP2 cp ../rnd DELETE3 mv tmpdir/subdir . rmdir tmpdir cp ../rnd DELETE4 rm DELETE* # and excercise the garbage collector cp ../rnd DELETE1 cp ../rnd DELETE2 cp ../rnd DELETE3 cp ../rnd DELETE4 cp ../rnd DELETE5 cp ../rnd DELETE6 cp ../rnd DELETE7 cp ../rnd DELETE8 cp ../rnd DELETE9 cp ../rnd DELETE1 cp ../rnd DELETE2 cp ../rnd DELETE3 cp ../rnd DELETE4 cp ../rnd DELETE5 cp ../rnd DELETE6 cp ../rnd DELETE7 cp ../rnd DELETE8 cp ../rnd DELETE9 cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE cp ../rnd DELETE rm DELETE* cd .. # unmount and remount partition. Notice how ls barfs after remount, but not before. ls -l mnt_jffs2 umount mnt_jffs2 mount -t jffs2 /dev/mtdblock0 mnt_jffs2 ls -l mnt_jffs2 # unmount again for next run umount mnt_jffs2