projects
/
project
/
ubox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
logd: fix time passed via unix fd
[project/ubox.git]
/
mount_root.c
diff --git
a/mount_root.c
b/mount_root.c
index f1474f0a2beee89ea9722a009baf3ba4dbe7df7d..1927efa13f45911196e5260bc513ddc933bfe611 100644
(file)
--- a/
mount_root.c
+++ b/
mount_root.c
@@
-109,12
+109,16
@@
static char* find_mount(char *mp)
while (fgets(line, sizeof(line), fp)) {
char *s, *t = strstr(line, " ");
while (fgets(line, sizeof(line), fp)) {
char *s, *t = strstr(line, " ");
- if (!t)
+ if (!t) {
+ fclose(fp);
return NULL;
return NULL;
+ }
t++;
s = strstr(t, " ");
t++;
s = strstr(t, " ");
- if (!s)
+ if (!s) {
+ fclose(fp);
return NULL;
return NULL;
+ }
*s = '\0';
if (!strcmp(t, mp)) {
*s = '\0';
if (!strcmp(t, mp)) {
@@
-143,13
+147,16
@@
static char* find_mount_point(char *block, char *fs)
char *p = &line[len + 1];
char *t = strstr(p, " ");
char *p = &line[len + 1];
char *t = strstr(p, " ");
- if (!t)
+ if (!t) {
+ fclose(fp);
return NULL;
return NULL;
+ }
*t = '\0';
t++;
if (fs && strncmp(t, fs, strlen(fs))) {
*t = '\0';
t++;
if (fs && strncmp(t, fs, strlen(fs))) {
+ fclose(fp);
ERROR("block is mounted with wrong fs\n");
return NULL;
}
ERROR("block is mounted with wrong fs\n");
return NULL;
}
@@
-423,6
+430,9
@@
static int switch2jffs(void)
{
char mtd[32];
{
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;
if (find_mtd_block("rootfs_data", mtd, sizeof(mtd))) {
ERROR("no rootfs_data was found\n");
return -1;
@@
-579,7
+589,7
@@
static int main_jffs2reset(int argc, char **argv)
mp = find_mount_point(mtd, "jffs2");
if (mp) {
mp = find_mount_point(mtd, "jffs2");
if (mp) {
- LOG("%s is mounted as %s, only er
e
asing 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 {
foreachdir(mp, handle_rmdir);
mount(mp, "/", NULL, MS_REMOUNT, 0);
} else {
@@
-687,11
+697,18
@@
static int extroot(const char *prefix)
sprintf(block_path, "%s/sbin/block", prefix);
if (stat(block_path, &s))
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);
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);
pid = fork();
if (!pid) {
mkdir("/tmp/extroot", 0755);
@@
-738,7
+755,11
@@
static int extroot(const char *prefix)
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;
}
}
return -1;
@@
-763,7
+784,9
@@
int main(int argc, char **argv)
if (!getenv("PREINIT"))
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");
if (!find_mtd_char("rootfs", mtd, sizeof(mtd)))
mtd_unlock(mtd);
LOG("mounting /dev/root\n");