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 '
'on /system to apply patches.");') % (amount,))
def Mount(self, mount_point):
"""Mount the partition with the given mount_point."""
def Mount(self, mount_point, mount_options_by_format=""):
"""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)
if fstab:
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.device, p.mount_point))
p.device, p.mount_point, mount_dict.get(p.fs_type, "")))
self.mounts.add(p.mount_point)
def UnpackPackageDir(self, src, dst):