From fe92e2e2b485967b8e6c62f7c6c3d7fde90c39f4 Mon Sep 17 00:00:00 2001 From: eatradish Date: Fri, 10 Nov 2023 20:35:15 +0800 Subject: [PATCH] utils.py: raise error if rootfs file size is not multiple of 4KiB. See: https://github.com/AOSC-Dev/aosc-asahi-installer/commit/f46e12d37e7f7b3ec41c9322510f6a4b83855dd0, if rootfs image size can not multipie of 4KiB, asahi-installer will raise `EINVAL`, users don't know whats happen ... The point of this commit is to look for illegitimate rootfs image sizes in advance, so that the raise error becomes clear. Signed-off-by: eatradish --- src/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util.py b/src/util.py index 872f699..b8692e0 100644 --- a/src/util.py +++ b/src/util.py @@ -149,6 +149,8 @@ def extract(self, src, dest): self.pkg.extract(src, dest) def fdcopy(self, sfd, dfd, size=None): + if size is not None and size % (4 * 1024) != 0: + raise Exception("The size of the rootfs image file must be a multiple of 4KiB.") BLOCK = 16 * 1024 * 1024 copied = 0 bps = 0