Allow info_dict from target_files to specify mount options

This will allow safer mount options to be added per mount FS
type, to better ensure data is written during an OTA.
Bug: 18079773, 18092222

Change-Id: I1e3e4fd4639c6fd263e550b770cc3c858ef1e03b
This commit is contained in:
Michael Runge
2014-10-22 17:21:48 -07:00
parent f84e045e42
commit 7cd99bad21
2 changed files with 27 additions and 11 deletions

View File

@@ -164,14 +164,25 @@ class EdifyGenerator(object):
self.script.append(('apply_patch_space(%d) || abort("Not enough free space ' self.script.append(('apply_patch_space(%d) || abort("Not enough free space '
'on /system to apply patches.");') % (amount,)) 'on /system to apply patches.");') % (amount,))
def Mount(self, mount_point): def Mount(self, mount_point, mount_options_by_format=""):
"""Mount the partition with the given mount_point.""" """Mount the partition with the given mount_point.
mount_options_by_format:
[fs_type=option[,option]...[|fs_type=option[,option]...]...]
where option is optname[=optvalue]
E.g. ext4=barrier=1,nodelalloc,errors=panic|f2fs=errors=recover
"""
fstab = self.info.get("fstab", None) fstab = self.info.get("fstab", None)
if fstab: if fstab:
p = fstab[mount_point] p = fstab[mount_point]
self.script.append('mount("%s", "%s", "%s", "%s");' % mount_dict = {}
if mount_options_by_format is not None:
for option in mount_options_by_format.split("|"):
if "=" in option:
key, value = option.split("=", 1)
mount_dict[key] = value
self.script.append('mount("%s", "%s", "%s", "%s", "%s");' %
(p.fs_type, common.PARTITION_TYPES[p.fs_type], (p.fs_type, common.PARTITION_TYPES[p.fs_type],
p.device, p.mount_point)) p.device, p.mount_point, mount_dict.get(p.fs_type, "")))
self.mounts.add(p.mount_point) self.mounts.add(p.mount_point)
def UnpackPackageDir(self, src, dst): def UnpackPackageDir(self, src, dst):

View File

@@ -462,11 +462,12 @@ def WriteFullOTAPackage(input_zip, output_zip):
script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict) script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties") oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
recovery_mount_options = OPTIONS.info_dict.get("recovery_mount_options")
oem_dict = None oem_dict = None
if oem_props is not None and len(oem_props) > 0: if oem_props is not None and len(oem_props) > 0:
if OPTIONS.oem_source is None: if OPTIONS.oem_source is None:
raise common.ExternalError("OEM source required for this build") raise common.ExternalError("OEM source required for this build")
script.Mount("/oem") script.Mount("/oem", recovery_mount_options)
oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines()) oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
metadata = {"post-build": CalculateFingerprint( metadata = {"post-build": CalculateFingerprint(
@@ -548,6 +549,8 @@ else if get_stage("%(bcb_dev)s", "stage") == "3/3" then
if "selinux_fc" in OPTIONS.info_dict: if "selinux_fc" in OPTIONS.info_dict:
WritePolicyConfig(OPTIONS.info_dict["selinux_fc"], output_zip) WritePolicyConfig(OPTIONS.info_dict["selinux_fc"], output_zip)
recovery_mount_options = OPTIONS.info_dict.get("recovery_mount_options")
system_items = ItemSet("system", "META/filesystem_config.txt") system_items = ItemSet("system", "META/filesystem_config.txt")
script.ShowProgress(system_progress, 0) script.ShowProgress(system_progress, 0)
if block_based: if block_based:
@@ -561,7 +564,7 @@ else if get_stage("%(bcb_dev)s", "stage") == "3/3" then
system_diff.WriteScript(script, output_zip) system_diff.WriteScript(script, output_zip)
else: else:
script.FormatPartition("/system") script.FormatPartition("/system")
script.Mount("/system") script.Mount("/system", recovery_mount_options)
if not has_recovery_patch: if not has_recovery_patch:
script.UnpackPackageDir("recovery", "/system") script.UnpackPackageDir("recovery", "/system")
script.UnpackPackageDir("system", "/system") script.UnpackPackageDir("system", "/system")
@@ -594,7 +597,7 @@ else if get_stage("%(bcb_dev)s", "stage") == "3/3" then
vendor_diff.WriteScript(script, output_zip) vendor_diff.WriteScript(script, output_zip)
else: else:
script.FormatPartition("/vendor") script.FormatPartition("/vendor")
script.Mount("/vendor") script.Mount("/vendor", recovery_mount_options)
script.UnpackPackageDir("vendor", "/vendor") script.UnpackPackageDir("vendor", "/vendor")
symlinks = CopyPartitionFiles(vendor_items, input_zip, output_zip) symlinks = CopyPartitionFiles(vendor_items, input_zip, output_zip)
@@ -745,11 +748,12 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
vendor_diff = None vendor_diff = None
oem_props = OPTIONS.target_info_dict.get("oem_fingerprint_properties") oem_props = OPTIONS.target_info_dict.get("oem_fingerprint_properties")
recovery_mount_options = OPTIONS.target_info_dict.get("recovery_mount_options")
oem_dict = None oem_dict = None
if oem_props is not None and len(oem_props) > 0: if oem_props is not None and len(oem_props) > 0:
if OPTIONS.oem_source is None: if OPTIONS.oem_source is None:
raise common.ExternalError("OEM source required for this build") raise common.ExternalError("OEM source required for this build")
script.Mount("/oem") script.Mount("/oem", recovery_mount_options)
oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines()) oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
AppendAssertions(script, OPTIONS.target_info_dict, oem_dict) AppendAssertions(script, OPTIONS.target_info_dict, oem_dict)
@@ -1035,11 +1039,12 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
OPTIONS.target_info_dict) OPTIONS.target_info_dict)
oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties") oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
recovery_mount_options = OPTIONS.info_dict.get("recovery_mount_options")
oem_dict = None oem_dict = None
if oem_props is not None and len(oem_props) > 0: if oem_props is not None and len(oem_props) > 0:
if OPTIONS.oem_source is None: if OPTIONS.oem_source is None:
raise common.ExternalError("OEM source required for this build") raise common.ExternalError("OEM source required for this build")
script.Mount("/oem") script.Mount("/oem", recovery_mount_options)
oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines()) oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
metadata = {"pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict, metadata = {"pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
@@ -1059,10 +1064,10 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
info_dict=OPTIONS.info_dict) info_dict=OPTIONS.info_dict)
system_diff = FileDifference("system", source_zip, target_zip, output_zip) system_diff = FileDifference("system", source_zip, target_zip, output_zip)
script.Mount("/system") script.Mount("/system", recovery_mount_options)
if HasVendorPartition(target_zip): if HasVendorPartition(target_zip):
vendor_diff = FileDifference("vendor", source_zip, target_zip, output_zip) vendor_diff = FileDifference("vendor", source_zip, target_zip, output_zip)
script.Mount("/vendor") script.Mount("/vendor", recovery_mount_options)
else: else:
vendor_diff = None vendor_diff = None