[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel,v2,4/4] Modify vfscore/Config.uk to autoselect RamFS and ukcpio



Also I change if-else-endif block

Signed-off-by: gabrielmocanu <gabi.mocanu98@xxxxxxxxx>
---
 lib/Makefile.uk       |  2 +-
 lib/vfscore/Config.uk | 17 +++++++++-------
 lib/vfscore/rootfs.c  | 45 ++++++++++++++++++++++---------------------
 3 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index ff69dfa..7c90723 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -21,7 +21,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/syscall_shim))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/vfscore))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ramfs))
-$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/cpio))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukcpio))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/devfs))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/9pfs))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uklock))
diff --git a/lib/vfscore/Config.uk b/lib/vfscore/Config.uk
index ef969bf..9938b12 100644
--- a/lib/vfscore/Config.uk
+++ b/lib/vfscore/Config.uk
@@ -9,9 +9,6 @@ config LIBVFSCORE
 if LIBVFSCORE
 menu "vfscore: Configuration"
 
-config LIBCPIO
-    bool "cpio: general cpio archive extraction"
-    default n
 
 config LIBINITRAMFS
     bool "initramfs: extract the given cpio file to /"
@@ -50,6 +47,11 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
                select LIBUK9P
                select LIB9PFS
 
+    config LIBVFSCORE_ROOTFS_INITRD
+    bool "InitRD"
+    select LIBRAMFS
+    select LIBUKCPIO
+
                config LIBVFSCORE_ROOTFS_CUSTOM
                bool "Custom argument"
                help
@@ -73,13 +75,14 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
        string
        default "ramfs" if LIBVFSCORE_ROOTFS_RAMFS
        default "9pfs" if LIBVFSCORE_ROOTFS_9PFS
-       default LIBVFSCORE_ROOTFS_CUSTOM_ARG if LIBVFSCORE_ROOTFS_CUSTOM
+       default "initrd" if LIBVFSCORE_ROOTFS_INITRD
+  default LIBVFSCORE_ROOTFS_CUSTOM_ARG if LIBVFSCORE_ROOTFS_CUSTOM
        default ""
 
        # The root device option is hidden for RamFS and 9PFS
        config LIBVFSCORE_ROOTDEV
        string "Default root device"
-       depends on !LIBVFSCORE_ROOTFS_RAMFS
+       depends on !LIBVFSCORE_ROOTFS_RAMFS && !LIBVFSCORE_ROOTFS_INITRD
        default "rootfs" if LIBVFSCORE_ROOTFS_9PFS
        default ""
        help
@@ -90,7 +93,7 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
        # The root flags is hidden for RamFS
        config LIBVFSCORE_ROOTFLAGS
        hex "Default root mount flags"
-       depends on !LIBVFSCORE_ROOTFS_RAMFS
+       depends on !LIBVFSCORE_ROOTFS_RAMFS && !LIBVFSCORE_ROOTFS_INITRD
        default 0x0
        help
                Mount flags.
@@ -98,7 +101,7 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
        # The root options are hidden for RamFS
        config LIBVFSCORE_ROOTOPTS
        string "Default root mount options"
-       depends on !LIBVFSCORE_ROOTFS_RAMFS
+       depends on !LIBVFSCORE_ROOTFS_RAMFS && !LIBVFSCORE_ROOTFS_INITRD
        default ""
        help
                Usually a comma-separated list of additional mount
diff --git a/lib/vfscore/rootfs.c b/lib/vfscore/rootfs.c
index 78dbe3a..e83eec8 100644
--- a/lib/vfscore/rootfs.c
+++ b/lib/vfscore/rootfs.c
@@ -85,32 +85,33 @@ static int vfscore_rootfs(void)
                return -1;
        }
 
-#ifdef CONFIG_LIBINITRAMFS
-       struct ukplat_memregion_desc memregion_desc;
-       int initrd;
-       enum cpio_error error;
+#if CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS
+       if (strncmp(rootfs, "initrd", 5) == 0) {
+               struct ukplat_memregion_desc initrd;
+               enum ukcpio_error error;
 
-       initrd = ukplat_memregion_find_initrd0(&memregion_desc);
-       if (initrd != -1) {
-               ukplat_memregion_get(initrd, &memregion_desc);
-               if (mount("", "/", "ramfs", 0, NULL) < 0)
-                       return -CPIO_MOUNT_FAILED;
+               if (ukplat_memregion_find_initrd0(&initrd) < 0){
+                       uk_pr_crit("Could not find an initrd!\n");
+                       return -1;
+               }
 
-               error =
-                   cpio_extract("/", memregion_desc.base, memregion_desc.len);
-               if (error < 0)
-                       uk_pr_err("Failed to mount initrd\n");
-               return error;
-       }
-       uk_pr_err("Failed to mount initrd\n");
-       return -CPIO_NO_MEMREGION;
-#else
-       uk_pr_info("Mount %s to /...\n", rootfs);
-       if (mount(rootdev, "/", rootfs, rootflags, rootopts) != 0) {
-               uk_pr_crit("Failed to mount /: %d\n", errno);
-               return -1;
+               if (mount("", "/", "ramfs", 0, NULL) != 0) {
+                       uk_pr_crit("Failed to mount ramfs to /: %d\n",
+                                  errno);
+                       return -1;
+               }
+
+               error = ukcpio_extract("/", initrd.base, initrd.len);
+               if (error < 0) {
+                       uk_pr_crit("Failed to extract cpio archive to /: %d\n",
+                                  error);
+                       return -1;
+               }
+
+               return 0;
        }
 #endif
+
        return 0;
 }
 
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.