]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
sandbox: Add better error reporting for overlayfs
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 15 Dec 2025 20:24:15 +0000 (21:24 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 Dec 2025 09:41:25 +0000 (10:41 +0100)
Let's do some basic checks up front so we catch
trivial errors ourselves instead of having to
debug obscure errors we get back from the kernel
when calling mount().

mkosi/sandbox.py

index bb10902aef855939db5297cecebbd97afd597b44..22829b90dd017b0403b257ca624c9994970df2c9 100755 (executable)
@@ -946,6 +946,16 @@ class OverlayOperation(FSOperation):
         workdir = chase(oldroot, self.workdir) if self.workdir else None
         dst = chase(newroot, self.dst)
 
+        for p in lowerdirs:
+            if not os.path.exists(p):
+                oserror("mount", p, ENOENT)
+
+        if upperdir and upperdir != "tmpfs" and upperdir != dst and not os.path.exists(upperdir):
+            oserror("mount", upperdir, ENOENT)
+
+        if workdir and not os.path.exists(workdir):
+            oserror("mount", workdir, ENOENT)
+
         with umask(~0o755):
             os.makedirs(os.path.dirname(dst), exist_ok=True)