- if (mount_move("/tmp", "", "/overlay")) {
- ERROR("moving extroot failed - continue normal boot\n");
- umount("/tmp/overlay");
- } else if (fopivot("/overlay", "/rom")) {
- ERROR("switching to extroot failed - continue normal boot\n");
- umount("/overlay");
- } else {
- return 0;
+ if (find_mount("/tmp/mnt")) {
+ mount("/dev/root", "/", NULL, MS_NOATIME | MS_REMOUNT | MS_RDONLY, 0);
+
+ mkdir("/tmp/mnt/proc", 0755);
+ mkdir("/tmp/mnt/dev", 0755);
+ mkdir("/tmp/mnt/sys", 0755);
+ mkdir("/tmp/mnt/tmp", 0755);
+ mkdir("/tmp/mnt/rom", 0755);
+
+ if (mount_move("/tmp", "", "/mnt")) {
+ ERROR("moving pivotroot failed - continue normal boot\n");
+ umount("/tmp/mnt");
+ } else if (pivot("/mnt", "/rom")) {
+ ERROR("switching to pivotroot failed - continue normal boot\n");
+ umount("/mnt");
+ } else {
+ return 0;
+ }
+ } else if (find_mount("/tmp/overlay")) {
+ if (mount_move("/tmp", "", "/overlay")) {
+ ERROR("moving extroot failed - continue normal boot\n");
+ umount("/tmp/overlay");
+ } else if (fopivot("/overlay", "/rom")) {
+ ERROR("switching to extroot failed - continue normal boot\n");
+ umount("/overlay");
+ } else {
+ return 0;
+ }