Support for ext2 and ext3 update-binary.

Change-Id: Ide34392bd8ac56878aa3e992b275a39d6b6bc7cf
diff --git a/mmcutils/mmcutils.c b/mmcutils/mmcutils.c
index de66090..7e283ef 100644
--- a/mmcutils/mmcutils.c
+++ b/mmcutils/mmcutils.c
@@ -318,9 +318,7 @@
 }
 
 int
-mmc_format_ext3 (MmcPartition *partition) {
-    char device[128];
-    strcpy(device, partition->device_index);
+format_ext3_device (const char *device) {
     // Run mke2fs
     char *const mke2fs[] = {MKE2FS_BIN, "-j", device, NULL};
     if(run_exec_process(mke2fs))
@@ -340,6 +338,33 @@
 }
 
 int
+format_ext2_device (const char *device) {
+    // Run mke2fs
+    char *const mke2fs[] = {MKE2FS_BIN, device, NULL};
+    if(run_exec_process(mke2fs))
+        return -1;
+
+    // Run tune2fs
+    char *const tune2fs[] = {TUNE2FS_BIN, "-C", "1", device, NULL};
+    if(run_exec_process(tune2fs))
+        return -1;
+
+    // Run e2fsck
+    char *const e2fsck[] = {E2FSCK_BIN, "-fy", device, NULL};
+    if(run_exec_process(e2fsck))
+        return -1;
+
+    return 0;
+}
+
+int
+mmc_format_ext3 (MmcPartition *partition) {
+    char device[128];
+    strcpy(device, partition->device_index);
+    return format_ext3_device(device);
+}
+
+int
 mmc_mount_partition(const MmcPartition *partition, const char *mount_point,
         int read_only)
 {