From 4cfdd6a0fb18ebc55524d97a342b719d580e82f8 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 15 Jul 2024 14:07:22 -0400 Subject: [PATCH] mount: Consistently use `composefs` as source The "source" field for overlayfs isn't strictly meaningful, by default; but it's useful to identify at least the software that created the mount. Motivated by https://gitlab.com/redhat/centos-stream/containers/bootc/-/issues/301 where some QE testing noticed that an updated composefs using the new mount API didn't specify the source at all, so it ends up as `none`, but if we fall back to the legacy one it uses `overlayfs`. Change both to be `composefs`. Signed-off-by: Colin Walters --- libcomposefs/lcfs-mount.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libcomposefs/lcfs-mount.c b/libcomposefs/lcfs-mount.c index eb0ed142..d6801ec9 100644 --- a/libcomposefs/lcfs-mount.c +++ b/libcomposefs/lcfs-mount.c @@ -49,6 +49,11 @@ #include "lcfs-utils.h" #include "lcfs-internal.h" +// The "source" field for overlayfs isn't strictly meaningful, +// by default; but it's useful to identify at least the software that +// created the mount. +#define CFS_MOUNT_SOURCE "composefs" + #ifndef LOOP_CONFIGURE /* Snippet from util-linux/include/loopdev.h */ /* @@ -369,7 +374,7 @@ static errint_t lcfs_mount_ovl_legacy(struct lcfs_mount_state_s *state, char *im mount_flags |= MS_SILENT; errint_t err = 0; - res = mount("overlay", state->mountpoint, "overlay", mount_flags, + res = mount(CFS_MOUNT_SOURCE, state->mountpoint, "overlay", mount_flags, overlay_options); if (res != 0) { err = -errno; @@ -404,6 +409,10 @@ static errint_t lcfs_mount_ovl(struct lcfs_mount_state_s *state, char *imagemoun if (res == 0) return -ENOSYS; + res = syscall_fsconfig(fd_fs, FSCONFIG_SET_STRING, "source", CFS_MOUNT_SOURCE, 0); + if (res < 0) + return -errno; + res = syscall_fsconfig(fd_fs, FSCONFIG_SET_STRING, "metacopy", "on", 0); if (res < 0) return -errno;