OSDN Git Service

Add support for tuning partitions
authorMichael Runge <mrunge@google.com>
Fri, 21 Nov 2014 08:46:03 +0000 (00:46 -0800)
committerMichael Runge <mrunge@google.com>
Sat, 22 Nov 2014 05:11:06 +0000 (21:11 -0800)
Allow a simple mechanism to call tune2fs to modify an existing
partition without reformatting.

Bug: 18430740
Change-Id: I9210355b6bfec74d002d1f40b930330740f379a5

tools/releasetools/edify_generator.py

index 7d318a3..e52c264 100644 (file)
@@ -201,6 +201,17 @@ class EdifyGenerator(object):
     """Log a message to the screen (if the logs are visible)."""
     self.script.append('ui_print("%s");' % (message,))
 
+  def TunePartition(self, partition, *options):
+    fstab = self.info.get("fstab", None)
+    if fstab:
+      p = fstab[partition]
+      if (p.fs_type not in ( "ext2", "ext3", "ext4")):
+        raise ValueError("Partition %s cannot be tuned\n" % (partition,))
+    self.script.append('tune2fs(' +
+                       "".join(['"%s", ' % (i,) for i in options]) +
+                       '"%s") || abort("Failed to tune partition %s");'
+                       % ( p.device,partition));
+
   def FormatPartition(self, partition):
     """Format the given partition, specified by its mount point (eg,
     "/system")."""