validate: range and base arguments for numeric types, new types hexstring, regexp...
[project/ubox.git] / mount_root.c
index ede5718..1927efa 100644 (file)
@@ -109,12 +109,16 @@ static char* find_mount(char *mp)
        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)) {
@@ -143,13 +147,16 @@ static char* find_mount_point(char *block, char *fs)
                        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;
                        }
@@ -690,11 +697,18 @@ static int extroot(const char *prefix)
        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);
@@ -741,7 +755,11 @@ static int extroot(const char *prefix)
                                        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;