files: overlayfs-etc: refactor preinit template
PATCH 1/2 files: overlayfs-etc: refactor preinit template
From: Vyacheslav Yurkov <[email protected]>
Signed-off-by Vyacheslav Yurkov <[email protected]>
Signed-off-by Alexandre Belloni <[email protected]>
Signed-off-by Richard Purdie <[email protected]>
--- meta/files/overlayfs-etc-preinit.sh.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
meta/files/overlayfs-etc-preinit.sh.in +9 -5
@@ -15,19 +15,23 @@ mount -t sysfs sysfs /sys [ -z "$CONSOLE" ] && CONSOLE="/dev/console" +BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc +UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper +WORK_DIR=$BASE_OVERLAY_ETC_DIR/work + mkdir -p {OVERLAYFS_ETC_MOUNT_POINT} if mount -n -t {OVERLAYFS_ETC_FSTYPE} \ -o {OVERLAYFS_ETC_MOUNT_OPTIONS} \ {OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT} then - mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper - mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/work + mkdir -p $UPPER_DIR + mkdir -p $WORK_DIR mount -n -t overlay \ - -o upperdir={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper \ + -o upperdir=$UPPER_DIR \ -o lowerdir=/etc \ - -o workdir={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/work \ + -o workdir=$WORK_DIR \ -o index=off,xino=off,redirect_dir=off,metacopy=off \ - {OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc/upper /etc || \ + $UPPER_DIR /etc || \ echo "PREINIT: Mounting etc-overlay failed!" else echo "PREINIT: Mounting </data> failed!"
Signature · 1 line
2.30.2
PATCH 2/2 classes: files: Extend overlayfs-etc class
From: Vyacheslav Yurkov <[email protected]>
Add the ability to expose the lower layer of /etc when mounting overlay. This is the similar to what overlayroot script from initramfs-framework does.
By default, this option is turned off to keep an old behavior intact.
Signed-off-by Vyacheslav Yurkov <[email protected]>
Signed-off-by Alexandre Belloni <[email protected]>
Signed-off-by Richard Purdie <[email protected]>
--- meta/classes/overlayfs-etc.bbclass | 5 ++++- meta/files/overlayfs-etc-preinit.sh.in | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
meta/classes/overlayfs-etc.bbclass +4 -1
@@ -34,6 +34,7 @@ OVERLAYFS_ETC_DEVICE ??= "" OVERLAYFS_ETC_USE_ORIG_INIT_NAME ??= "1" OVERLAYFS_ETC_MOUNT_OPTIONS ??= "defaults" OVERLAYFS_ETC_INIT_TEMPLATE ??= "${COREBASE}/meta/files/overlayfs-etc-preinit.sh.in" +OVERLAYFS_ETC_EXPOSE_LOWER ??= "0" python create_overlayfs_etc_preinit() { overlayEtcMountPoint = d.getVar("OVERLAYFS_ETC_MOUNT_POINT")
@@ -54,13 +55,15 @@ python create_overlayfs_etc_preinit() { preinitPath = oe.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("base_sbindir"), "preinit") initBaseName = oe.path.join(d.getVar("base_sbindir"), "init") origInitNameSuffix = ".orig" + exposeLower = oe.types.boolean(d.getVar('OVERLAYFS_ETC_EXPOSE_LOWER')) args = { 'OVERLAYFS_ETC_MOUNT_POINT': overlayEtcMountPoint, 'OVERLAYFS_ETC_MOUNT_OPTIONS': d.getVar('OVERLAYFS_ETC_MOUNT_OPTIONS'), 'OVERLAYFS_ETC_FSTYPE': overlayEtcFsType, 'OVERLAYFS_ETC_DEVICE': overlayEtcDevice, - 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName + 'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName, + 'OVERLAYFS_ETC_EXPOSE_LOWER': "true" if exposeLower else "false" } if useOrigInit:
meta/files/overlayfs-etc-preinit.sh.in +9 -0
@@ -18,6 +18,7 @@ mount -t sysfs sysfs /sys BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper WORK_DIR=$BASE_OVERLAY_ETC_DIR/work +LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower mkdir -p {OVERLAYFS_ETC_MOUNT_POINT} if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
@@ -26,6 +27,14 @@ if mount -n -t {OVERLAYFS_ETC_FSTYPE} \ then mkdir -p $UPPER_DIR mkdir -p $WORK_DIR + + if {OVERLAYFS_ETC_EXPOSE_LOWER}; then + mkdir -p $LOWER_DIR + + # provide read-only access to original /etc content + mount -o bind,ro /etc $LOWER_DIR + fi + mount -n -t overlay \ -o upperdir=$UPPER_DIR \ -o lowerdir=/etc \
Signature · 1 line
2.30.2