Skip to content

Commit

Permalink
mount: Consistently use composefs as source
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cgwalters committed Jul 15, 2024
1 parent 45e6179 commit 4cfdd6a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libcomposefs/lcfs-mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4cfdd6a

Please sign in to comment.