block: ignore probe entries without id
[project/ubox.git] / block.c
diff --git a/block.c b/block.c
index 15f4b0f..7d0781e 100644 (file)
--- a/block.c
+++ b/block.c
@@ -327,7 +327,7 @@ static int _cache_load(const char *path)
                struct blkid_struct_probe *pr = malloc(sizeof(struct blkid_struct_probe));
                memset(pr, 0, sizeof(struct blkid_struct_probe));
                probe_block(gl.gl_pathv[j], pr);
-               if (pr->err)
+               if (pr->err || !pr->id)
                        free(pr);
                else
                        list_add_tail(&pr->list, &devices);
@@ -344,6 +344,8 @@ static void cache_load(int mtd)
                _cache_load("/dev/mtdblock*");
        _cache_load("/dev/mmcblk*");
        _cache_load("/dev/sd*");
+       _cache_load("/dev/sdc*");
+       _cache_load("/dev/hd*");
 }
 
 static int print_block_info(struct blkid_struct_probe *pr)
@@ -377,7 +379,7 @@ static int print_block_uci(struct blkid_struct_probe *pr)
        if (pr->uuid[0])
                printf("\toption\tuuid\t'%s'\n", pr->uuid);
        else
-               printf("\toption\tdevice\t'%s'\n", basename(pr->dev));
+               printf("\toption\tdevice\t'%s'\n", pr->dev);
        printf("\toption\tenabled\t'0'\n\n");
 
        return 0;
@@ -456,11 +458,10 @@ static void check_filesystem(struct blkid_struct_probe *pr)
                return;
        }
 
-       if (stat(e2fsck, &statbuf) < 0)
-               return;
-
-       if (!(statbuf.st_mode & S_IXUSR))
+       if (stat(e2fsck, &statbuf) < 0) {
+               fprintf(stderr, "check_filesystem: %s not found\n", e2fsck);
                return;
+       }
 
        pid = fork();
        if (!pid) {
@@ -468,7 +469,10 @@ static void check_filesystem(struct blkid_struct_probe *pr)
                exit(-1);
        } else if (pid > 0) {
                int status;
+
                waitpid(pid, &status, 0);
+               if (WEXITSTATUS(status))
+                       fprintf(stderr, "check_filesystem: %s returned %d\n", e2fsck, WEXITSTATUS(status));
        }
 }
 
@@ -710,6 +714,8 @@ static int mount_extroot(char *cfg)
        if (!pr && delay_root){
                fprintf(stderr, "extroot: is not ready yet, retrying in %ui seconds\n", delay_root);
                sleep(delay_root);
+               mkblkdev();
+               cache_load(0);
                pr = find_block_info(m->uuid, m->label, NULL);
        }
        if (pr) {