On 04/05/22 05:13, George Prekas wrote:
Even when supplied with $SUPERMIN_MODULES, supermin tries to access
/lib/modules. This directory does not exist by default in all the
environments.
---
src/format_ext2.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/format_ext2.ml b/src/format_ext2.ml
index e311ea6..2783473 100644
--- a/src/format_ext2.ml
+++ b/src/format_ext2.ml
@@ -95,8 +95,8 @@ let build_ext2 debug basedir files modpath kernel_version appliance
size
printf "supermin: ext2: copying kernel modules\n%!";
(* Import the kernel modules. *)
- ext2fs_copy_file_from_host fs "/lib" "/lib";
- ext2fs_copy_file_from_host fs "/lib/modules" "/lib/modules";
+ ext2fs_copy_file_from_host fs "/" "/lib";
+ ext2fs_copy_file_from_host fs "/" "/lib/modules";
ext2fs_copy_dir_recursively_from_host fs
modpath ("/lib/modules/" ^ kernel_version);
The issue seems a bit complicated. AIUI, we always want the modules
under /lib/modules/ in the appliance; the question is where we take the
ownership, file mode bits, timestamps etc for those destination
(in-appliance) directories (/lib and /lib/modules) from.
Something like:
- if /lib exists on the host and SUPERMIN_MODULES is not set, or starts
with /lib/, then copy the metadata from /lib/ into the appliance.
Otherwise, create /lib in the appliance with some default metadata.
- if /lib was copied in the previous step, then repeat the same logic
for /lib/modules.
Now that would be clearly too complex, so the suggested change might
make sense; however there is some black magic in ext2_copy_file() with
regard to symlinks, and on my system I have
dr-xr-xr-x. 18 root root 4096 2022-02-22 16:40:56 +0100 /
lrwxrwxrwx. 1 root root 7 2018-08-29 19:03:38 +0200 /lib -> usr/lib
drwxr-xr-x. 9 root root 4096 2022-03-08 08:02:01 +0100 /lib/modules
so simply removing that symlink-related cleverness from the picture is
likely wrong.
Instead, can you perhaps wrap those two lines into a try/with, and if
you catch a Unix_error exception, then do this simpler logic?
(I do defer to Rich on this however.)
Thanks
Laszlo