while (fgets(line, sizeof(line), fp)) {
char *s, *t = strstr(line, " ");
- if (!t)
+ if (!t) {
+ fclose(fp);
return NULL;
+ }
t++;
s = strstr(t, " ");
- if (!s)
+ if (!s) {
+ fclose(fp);
return NULL;
+ }
*s = '\0';
if (!strcmp(t, mp)) {
char *p = &line[len + 1];
char *t = strstr(p, " ");
- if (!t)
+ if (!t) {
+ fclose(fp);
return NULL;
+ }
*t = '\0';
t++;
if (fs && strncmp(t, fs, strlen(fs))) {
+ fclose(fp);
ERROR("block is mounted with wrong fs\n");
return NULL;
}
{
char mtd[32];
+ if (!find_mtd_block("rootfs_patches", mtd, sizeof(mtd)))
+ return 0;
+
if (find_mtd_block("rootfs_data", mtd, sizeof(mtd))) {
ERROR("no rootfs_data was found\n");
return -1;
mp = find_mount_point(mtd, "jffs2");
if (mp) {
- LOG("%s is mounted as %s, only ereasing files\n", mtd, mp);
+ LOG("%s is mounted as %s, only erasing files\n", mtd, mp);
foreachdir(mp, handle_rmdir);
mount(mp, "/", NULL, MS_REMOUNT, 0);
} else {
sprintf(block_path, "%s/sbin/block", prefix);
if (stat(block_path, &s))
- return -1;
+ {
+ sprintf(block_path, "/sbin/block");
+
+ if (stat(block_path, &s))
+ return -1;
+ }
sprintf(kmod_loader, "/sbin/kmodloader %s/etc/modules-boot.d/ %s", prefix, prefix);
system(kmod_loader);
+ LOG("starting block executable %s\n", block_path);
+
pid = fork();
if (!pid) {
mkdir("/tmp/extroot", 0755);
ERROR("switching to pivotroot failed - continue normal boot\n");
umount("/mnt");
} else {
+ umount("/tmp/overlay");
+ rmdir("/tmp/overlay");
rmdir("/tmp/extroot/mnt");
rmdir("/tmp/extroot");
return 0;
rmdir("/tmp/extroot");
return 0;
}
+ } else {
+ ERROR("block executable did not set up an overlay\n");
}
+ } else {
+ ERROR("block executable failed with code %d\n", WEXITSTATUS(status));
}
}
return -1;
if (!getenv("PREINIT"))
return -1;
- if (find_mtd_char("rootfs_data", mtd, sizeof(mtd))) {
+ if (!find_mtd_block("rootfs_patches", mtd, sizeof(mtd))) {
+ ramoverlay();
+ } else if (find_mtd_char("rootfs_data", mtd, sizeof(mtd))) {
if (!find_mtd_char("rootfs", mtd, sizeof(mtd)))
mtd_unlock(mtd);
LOG("mounting /dev/root\n");