]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes: rootfs-postcommands: include /etc/fstab in overlayfs_qa_check
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Wed, 2 Mar 2022 14:33:28 +0000 (15:33 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 4 Mar 2022 17:13:06 +0000 (17:13 +0000)
The systemd init manager support mount point configuration via mount
units and /etc/fstab. 'Mounts listed in /etc/fstab will be converted
into native units dynamically at boot and when the configuration of
the system manager is reloaded. In general, configuring mount points
through /etc/fstab is the preferred approach.' [1]

Read mount points from /etc/fstab to determine dynamic mount units.

[1] https://www.freedesktop.org/software/systemd/man/systemd.mount.html

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/rootfs-postcommands.bbclass
meta/lib/oeqa/selftest/cases/overlayfs.py

index b63a5b90d3b94f68e8a0ffb23a3ffee6c3d126af..7b92df69c5813cb6f0a20067a52d73b27a73f6d6 100644 (file)
@@ -372,25 +372,45 @@ rootfs_reproducible () {
        fi
 }
 
+# Perform a dumb check for unit existence, not its validity
 python overlayfs_qa_check() {
     from oe.overlayfs import mountUnitName
 
-    # this is a dumb check for unit existence, not its validity
     overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT") or {}
     imagepath = d.getVar("IMAGE_ROOTFS")
-    searchpaths = [oe.path.join(imagepath, d.getVar("sysconfdir"), "systemd", "system"),
+    sysconfdir = d.getVar("sysconfdir")
+    searchpaths = [oe.path.join(imagepath, sysconfdir, "systemd", "system"),
                    oe.path.join(imagepath, d.getVar("systemd_system_unitdir"))]
+    fstabpath = oe.path.join(imagepath, sysconfdir, "fstab")
+
+    if not any(os.path.exists(path) for path in [*searchpaths, fstabpath]):
+        return
+
+    fstabDevices = []
+    if os.path.isfile(fstabpath):
+        with open(fstabpath, 'r') as f:
+            for line in f:
+                if line[0] == '#':
+                    continue
+                path = line.split(maxsplit=2)
+                if len(path) > 2:
+                    fstabDevices.append(path[1])
 
     allUnitExist = True;
     for mountPoint in overlayMountPoints:
-        path = d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint)
-        unit = mountUnitName(path)
+        mountPath = d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint)
+        if mountPath in fstabDevices:
+            continue
+
+        mountUnit = mountUnitName(mountPath)
+        if any(os.path.isfile(oe.path.join(dirpath, mountUnit))
+               for dirpath in searchpaths):
+            continue
 
-        if not any(os.path.isfile(oe.path.join(dirpath, unit))
-                   for dirpath in searchpaths):
-            bb.warn('Unit name %s not found in systemd unit directories' % unit)
-            allUnitExist = False;
+        bb.warn('Mount path %s not found in fstat and unit %s not found '
+                'in systemd unit directories' % (mountPath, mountUnit))
+        allUnitExist = False;
 
     if not allUnitExist:
-        bb.fatal('Not all mount units are installed by the BSP')
+        bb.fatal('Not all mount paths and units are installed in the image')
 }
index 82007fade70105747455b519fc4a8e1223b71371..79d36fa93c159960730459b7c2571e85650684cb 100644 (file)
@@ -61,9 +61,9 @@ DISTRO_FEATURES += "systemd overlayfs"
         self.add_overlay_conf_to_machine()
 
         res = bitbake('core-image-minimal', ignore_status=True)
-        line = getline(res, "Unit name mnt-overlay.mount not found in systemd unit directories")
+        line = getline(res, " Mount path /mnt/overlay not found in fstat and unit mnt-overlay.mount not found in systemd unit directories")
         self.assertTrue(line and line.startswith("WARNING:"), msg=res.output)
-        line = getline(res, "Not all mount units are installed by the BSP")
+        line = getline(res, "Not all mount paths and units are installed in the image")
         self.assertTrue(line and line.startswith("ERROR:"), msg=res.output)
 
     def test_mount_unit_not_set(self):