add squashfsopts2 option for squashfs file system. 78/254678/1
authorbiao716.wang <biao716.wang@samsung.com>
Mon, 8 Mar 2021 07:39:17 +0000 (16:39 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Mon, 8 Mar 2021 07:39:20 +0000 (16:39 +0900)
If squashfs image size is larger than squashfsoptions2, mic will stop.
How to use in ks files
 "part /mnt/initrd --size=14 --ondisk mmcblk0p --fstype=squashfs --label=ramdisk --squashfsoptions2=4"

Change-Id: Ib55511137e178aea4a00fceb13619b8476925638
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/imager/loop.py
mic/kickstart/custom_commands/partition.py

index 3d128db9df9b651234e0ed5017df1bb2bddabbde..7f42e3da809577cdf9dc40949ac50e6b2d830e4e 100644 (file)
@@ -16,6 +16,7 @@
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import os
+import sys
 import glob
 import shutil
 
@@ -170,6 +171,7 @@ class LoopImageCreator(BaseImageCreator):
                     'f2fsopts': part.f2fsopts or None,
                     'vdfsopts': part.vdfsopts or None,
                     'squashfsopts': part.squashfsopts or None,
+                    'squashfsopts2': part.squashfsopts2 or None,
                     'cpioopts': part.cpioopts or None,
                     'loop': None,  # to be created in _mount_instroot
                     'uuid': part.uuid or None,
@@ -455,6 +457,13 @@ class LoopImageCreator(BaseImageCreator):
                     else:
                         runner.show("%s " % args)
 
+                    if item['squashfsopts2']:
+                        squashfsopts2=int(item['squashfsopts2']) * 1024 * 1024
+                        imgsize = os.stat(self._imgdir+"/"+item['label']+fs_suffix).st_size
+                        if imgsize > squashfsopts2:
+                            msger.error("squashfs img size is too large (%d > %d)" % (imgsize, squashfsopts2))
+                            sys.exit()
+
                 if item['aft_fstype'] == "vdfs":
                     ##FIXME temporary code - replace this with fs.mkvdfs()
                     if item['vdfsopts']:
index ae271e2f30d710cc9d13be1c38147f980a44b5f5..595b796d372771d3a6be0ab7fbe18289fc5e5ca0 100755 (executable)
@@ -32,6 +32,7 @@ class Mic_PartData(FC4_PartData):
         self.exclude_image = kwargs.get("exclude_from_image", False)
         self.vdfsopts = kwargs.get("vdfsopts", None)
         self.squashfsopts = kwargs.get("squashfsopts", None)
+        self.squashfsopts2 = kwargs.get("squashfsopts2", None)
         self.cpioopts = kwargs.get("cpioopts", None)
         self.no_shrink = kwargs.get("no_shrink", False)
         self.init_expand = kwargs.get("init_expand", False)
@@ -55,6 +56,8 @@ class Mic_PartData(FC4_PartData):
             retval += " --vdfsoptions=%s" % self.vdfsopts
         if self.squashfsopts:
             retval += " --squashfsoptions=%s" % self.squashfsopts
+        if self.squashfsopts2:
+            retval += " --squashfsoptions2=%s" % self.squashfsopts2
         if self.cpioopts:
             retval += " --cpiooptions=%s" % self.cpioopts
         if self.no_shrink:
@@ -86,6 +89,8 @@ class Mic_Partition(FC4_Partition):
                       default=None)
         op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts",
                       default=None)
+        op.add_option("--squashfsoptions2", type="string", action="store", dest="squashfsopts2",
+                      default=None)
         op.add_option("--cpiooptions", type="string", action="store", dest="cpioopts",
                       default=None)
         op.add_option("--no-shrink", action="store_true", dest="no_shrink", default=False)