From: Simon Kuenzer Date: Mon, 28 Aug 2023 13:12:34 +0000 (+0200) Subject: lib/vfscore: Support initrds with `LIBVFSCORE_ROOTFS_CUSTOM` X-Git-Tag: RELEASE-0.15.0~83 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=de3621e495acf0636ee498667eb74b786a230f53;p=unikraft%2Funikraft.git lib/vfscore: Support initrds with `LIBVFSCORE_ROOTFS_CUSTOM` Commit 24be5b01a7da ("lib/vfscore: Implement individual volume automounting") disabled the ability to manually specify mounting of an initrd with `LIBVFSCORE_ROOTFS_CUSTOM`. Initrd support depends on `LIBUKCPIO` and `LIBRAMFS`. This commit brings back this feature. Signed-off-by: Simon Kuenzer Reviewed-by: Cezar Craciunoiu Reviewed-by: Sergiu Moga Reviewed-by: Marco Schlumpp Approved-by: Marco Schlumpp GitHub-Closes: #1070 --- diff --git a/lib/vfscore/automount.c b/lib/vfscore/automount.c index ece97032a..7d981cd6b 100644 --- a/lib/vfscore/automount.c +++ b/lib/vfscore/automount.c @@ -151,7 +151,7 @@ static void vfscore_fstab_fetch_volume_args(char *v, struct vfscore_volume *vv) } #endif /* CONFIG_LIBVFSCORE_FSTAB */ -#ifdef CONFIG_LIBUKCPIO +#if CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS static int vfscore_mount_initrd_volume(struct vfscore_volume *vv) { struct ukplat_memregion_desc *initrd; @@ -187,13 +187,7 @@ static int vfscore_mount_initrd_volume(struct vfscore_volume *vv) return 0; } - -#else /* CONFIG_LIBUKCPIO */ -static int vfscore_mount_initrd_volume(struct vfscore_volume *vv __unused) -{ - return -1; -} -#endif /* !CONFIG_LIBUKCPIO */ +#endif /* CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS */ #ifdef CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS static int vfscore_automount_rootfs(void) @@ -230,10 +224,10 @@ static int vfscore_automount_rootfs(void) if (!vv.drv || vv.drv[0] == '\0') return 0; -#if CONFIG_LIBVFSCORE_ROOTFS_INITRD +#if CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS if (!strncmp(vv.drv, "initrd", sizeof("initrd") - 1)) return vfscore_mount_initrd_volume(&vv); -#endif /* CONFIG_LIBVFSCORE_ROOTFS_INITRD */ +#endif /* CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS */ rc = vfscore_mount_volume(&vv); if (unlikely(rc)) @@ -258,10 +252,14 @@ static int vfscore_automount_fstab_volumes(void) for (i = 0; i < CONFIG_LIBVFSCORE_FSTAB_SIZE && vfscore_fstab[i]; i++) { vfscore_fstab_fetch_volume_args(vfscore_fstab[i], &vv); - if (!strncmp(vv.drv, "initrd", sizeof("initrd") - 1)) +#if CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS + if (!strncmp(vv.drv, "initrd", sizeof("initrd") - 1)) { rc = vfscore_mount_initrd_volume(&vv); - else + } else +#endif /* CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS */ + { rc = vfscore_mount_volume(&vv); + } if (unlikely(rc)) { uk_pr_err("Failed to mount %s: error %d\n", vv.sdev, rc);