--- trunk/mkinitrd-magellan/klibc/usr/kinit/do_mounts.c 2010/07/22 07:47:49 1121 +++ trunk/mkinitrd-magellan/klibc/usr/kinit/do_mounts.c 2010/08/18 21:11:40 1122 @@ -33,8 +33,8 @@ int fd; if (type) { - DEBUG(("kinit: trying to mount %s on %s with type %s\n", - source, target, type)); + dprintf("kinit: trying to mount %s on %s with type %s\n", + source, target, type); int rv = mount(source, target, type, flags, data); /* Mount readonly if necessary */ if (rv == -1 && errno == EACCES && !(flags & MS_RDONLY)) @@ -52,16 +52,16 @@ close(fd); if (!err && type) { - DEBUG(("kinit: %s appears to be a %s filesystem\n", - source, type)); + dprintf("kinit: %s appears to be a %s filesystem\n", + source, type); type = mount_block(source, target, type, flags, data); if (type) return type; } } - DEBUG(("kinit: failed to identify filesystem %s, trying all\n", - source)); + dprintf("kinit: failed to identify filesystem %s, trying all\n", + source); fsbytes = readfile("/proc/filesystems", &fslist); @@ -139,6 +139,30 @@ return 0; } +static int +mount_roots(int argc, char *argv[], const char *root_dev_name) +{ + char *roots = strdup(root_dev_name); + char *root; + const char *sep = ","; + char *saveptr; + int ret = -ESRCH; + + root = strtok_r(roots, sep, &saveptr); + while (root) { + dev_t root_dev; + + dprintf("kinit: trying to mount %s\n", root); + root_dev = name_to_dev_t(root); + ret = mount_root(argc, argv, root_dev, root); + if (!ret) + break; + root = strtok_r(NULL, sep, &saveptr); + } + free(roots); + return ret; +} + int mount_root(int argc, char *argv[], dev_t root_dev, const char *root_dev_name) { @@ -147,7 +171,7 @@ const char *type = get_arg(argc, argv, "rootfstype="); if (get_flag(argc, argv, "rw") > get_flag(argc, argv, "ro")) { - DEBUG(("kinit: mounting root rw\n")); + dprintf("kinit: mounting root rw\n"); flags &= ~MS_RDONLY; } @@ -183,7 +207,7 @@ const char *load_ramdisk = get_arg(argc, argv, "load_ramdisk="); dev_t root_dev = 0; - DEBUG(("kinit: do_mounts\n")); + dprintf("kinit: do_mounts\n"); if (root_delay) { int delay = atoi(root_delay); @@ -205,17 +229,19 @@ root_dev = (dev_t) rootdev; } - DEBUG(("kinit: root_dev = %s\n", bdevname(root_dev))); + dprintf("kinit: root_dev = %s\n", bdevname(root_dev)); if (initrd_load(argc, argv, root_dev)) { - DEBUG(("initrd loaded\n")); + dprintf("initrd loaded\n"); return 0; } if (load_ramdisk && atoi(load_ramdisk)) { - if (ramdisk_load(argc, argv, root_dev)) + if (ramdisk_load(argc, argv)) root_dev = Root_RAM0; } + if (root_dev == Root_MULTI) + return mount_roots(argc, argv, root_dev_name); return mount_root(argc, argv, root_dev, root_dev_name); }