See the following in script Reset2default:
#!/usr/bin/lua
Local HWM = require "HWM"
Hwm.myexec ("Jffs2reset-y")
Os.exit (0)
Do not know the function of Jffs2reset, Baidu, found that the introduction of the few, in this, their own research.
First, execute the command "jffs2reset-y" to get the following result:
root@hbg:/# jffs2reset-y
/dev/mtdblock3 is mounted as/overlay, only erasing files
As you can tell, the content of the/DEV/MTDBLOCK3 is erased after the result is executed.
View partitions
root@hbg:/# CAT/PROC/MTD
Dev:size erasesize Name
mtd0:00040000 00010000 "U-boot"
mtd1:00010000 00010000 "U-boot-env"
mtd2:00e30000 00010000 "Rootfs"
mtd3:00a10000 00010000 "Rootfs_data"
mtd4:00150000 00010000 "Kernel"
learned that the content in Mtd3 is Rootfs_data, which is the related configuration part of the device.
To view the source code for Jffs2reset (located in fstools-2015-02-25.1):
File is jffs2reset.c
int main (int argc, char **argv)
{
if (!strcmp (*ARGV, "Jffs2mark"))
Return Jffs2_mark (argc, argv);
Return Jffs2_reset (argc, argv); With the parameter "-y", so go to this branch
}
To view the function Jffs2_reset, you can get the following:
static int
Jffs2_reset (int argc, char **argv)
{
struct volume *v;
Char *mp;
if (Ask_user (argc, argv))//See if the default parameter is "-y" and if no, you need to print the usage information
return-1;
if (Find_filesystem ("overlay")) {//Find the partition where the overlay is located
fprintf (stderr, "Overlayfs not found\n");
return-1;
}
v = volume_find ("Rootfs_data"); Find the volume where the Rootfs_data is located
if (!v) {
fprintf (stderr, "No rootfs_data was found\n");
return-1;
}
MP = Find_mount_point (v->blk, 1); Find mount points
if (MP) {
fprintf (stderr, "%s is mounted as%s, only erasing files\n", V->BLK, MP);
Foreachdir (MP, Handle_rmdir);
Mount (MP, "/", NULL, Ms_remount, 0); Re-mount
} else {
fprintf (stderr, "%s is not mounted, erasing it\n", v->blk);
Volume_erase_all (v);
}
return 0;
}
where Find_filesystem ("overlay") is called when looking in/proc/filesystems
root@hbg:/# Cat/proc/filesystems
Nodev Sysfs
Nodev Rootfs
Nodev Bdev
Nodev proc
Nodev TMPFS
Nodev Debugfs
Nodev SOCKFS
Nodev Pipefs
Nodev Anon_inodefs
Nodev devpts
Squashfs
Nodev Ramfs
Nodev JFFS2
Nodev OVERLAYFS
Nodev Mtd_inodefs
Ext3
Ext2
Ext4
Ntfs
Vfat
root@hbg:/#
MP = Find_mount_point (v->blk, 1); is to find/proc/mounts, where the value of V->BLK is overlay
root@hbg:/# cat/proc/mounts
Rootfs/rootfs RW 0 0
/dev/root/rom SQUASHFS ro,relatime 0 0
PROC/PROC proc Rw,noatime 0 0
Sysfs/sys Sysfs rw,noatime 0 0
Tmpfs/tmp Tmpfs rw,nosuid,nodev,noatime 0 0
/dev/mtdblock3/overlay JFFS2 rw,noatime 0 0
OVERLAYFS:/OVERLAY/OVERLAYFS Rw,relatime,lowerdir=/,upperdir=/overlay 0 0
Tmpfs/dev Tmpfs rw,relatime,size=512k,mode=755 0 0
Devpts/dev/pts devpts rw,relatime,mode=600 0 0
Debugfs/sys/kernel/debug Debugfs rw,noatime 0 0
Postscript:
Start equivalent to command:
Mtd-r Erase Rootfs_data
Transferred from: http://www.cnblogs.com/rohens-hbg/p/5604548.html