]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc/conf: handle rootfs open_at error in lxc_mount_rootfs
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Wed, 2 Apr 2025 08:52:16 +0000 (10:52 +0200)
committerAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Wed, 2 Apr 2025 08:52:16 +0000 (10:52 +0200)
If LXC build is misconfigured, for instance, --prefix=/
and /lib is a symlink to /usr/lib then open_at always fails
to open rootfs. Let's add error print to make it easier to
figure out this.

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
src/lxc/conf.c

index 1410ebe54a4b78e50e12879ae02c67eac386d017..f711d95b79fd61e88168aca08c93b08c29d72703 100644 (file)
@@ -1247,7 +1247,7 @@ static int lxc_mount_rootfs(struct lxc_rootfs *rootfs)
 
        rootfs->dfd_mnt = open_at(-EBADF, rootfs->mount, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
        if (rootfs->dfd_mnt < 0)
-               return -errno;
+               return log_error_errno(-1, errno, "Failed to open rootfs \"%s\"", rootfs->mount);
 
        return log_trace(0, "Container uses separate rootfs. Opened container's rootfs");
 }