Merge "Undo Utils dependency on VolumeManager"
diff --git a/model/Disk.cpp b/model/Disk.cpp
index 291c2e1..14de74f 100644
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -28,7 +28,6 @@
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
 #include <android-base/parseint.h>
-#include <diskconfig/diskconfig.h>
 #include <ext4_utils/ext4_crypt.h>
 
 #include <vector>
@@ -416,7 +415,6 @@
 status_t Disk::partitionPublic() {
     int res;
 
-    // TODO: improve this code
     destroyAllVolumes();
     mJustPartitioned = true;
 
@@ -432,41 +430,21 @@
         LOG(WARNING) << "Failed to zap; status " << res;
     }
 
-    struct disk_info dinfo;
-    memset(&dinfo, 0, sizeof(dinfo));
+    // Now let's build the new MBR table. We heavily rely on sgdisk to
+    // force optimal alignment on the created partitions.
+    cmd.clear();
+    cmd.push_back(kSgdiskPath);
+    cmd.push_back("--new=0:0:-0");
+    cmd.push_back("--typecode=0:0c00");
+    cmd.push_back("--gpttombr=1");
+    cmd.push_back(mDevPath);
 
-    if (!(dinfo.part_lst = (struct part_info *) malloc(
-            MAX_NUM_PARTS * sizeof(struct part_info)))) {
-        return -1;
+    if ((res = ForkExecvp(cmd)) != 0) {
+        LOG(ERROR) << "Failed to partition; status " << res;
+        return res;
     }
 
-    memset(dinfo.part_lst, 0, MAX_NUM_PARTS * sizeof(struct part_info));
-    dinfo.device = strdup(mDevPath.c_str());
-    dinfo.scheme = PART_SCHEME_MBR;
-    dinfo.sect_size = 512;
-    dinfo.skip_lba = 2048;
-    dinfo.num_lba = 0;
-    dinfo.num_parts = 1;
-
-    struct part_info *pinfo = &dinfo.part_lst[0];
-
-    pinfo->name = strdup("android_sdcard");
-    pinfo->flags |= PART_ACTIVE_FLAG;
-    pinfo->type = PC_PART_TYPE_FAT32;
-    pinfo->len_kb = -1;
-
-    int rc = apply_disk_config(&dinfo, 0);
-    if (rc) {
-        LOG(ERROR) << "Failed to apply disk configuration: " << rc;
-        goto out;
-    }
-
-out:
-    free(pinfo->name);
-    free(dinfo.device);
-    free(dinfo.part_lst);
-
-    return rc;
+    return OK;
 }
 
 status_t Disk::partitionPrivate() {
diff --git a/tests/Android.mk b/tests/Android.mk
index 8f2cda7..49da010 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -18,6 +18,7 @@
 LOCAL_MODULE := vold_tests
 LOCAL_MODULE_TAGS := eng tests
 
+LOCAL_CFLAGS := -Wall -Werror
 include $(BUILD_NATIVE_TEST)
 
 include $(CLEAR_VARS)
@@ -41,4 +42,5 @@
 LOCAL_MODULE := vold_cryptfs_scrypt_hidlization_equivalence_test
 LOCAL_MODULE_TAGS := eng tests
 
+LOCAL_CFLAGS := -Wall -Werror
 include $(BUILD_NATIVE_TEST)
diff --git a/tests/CryptfsScryptHidlizationEquivalence_test.cpp b/tests/CryptfsScryptHidlizationEquivalence_test.cpp
index 91ddb2b..3a6c029 100644
--- a/tests/CryptfsScryptHidlizationEquivalence_test.cpp
+++ b/tests/CryptfsScryptHidlizationEquivalence_test.cpp
@@ -369,6 +369,7 @@
     return keymaster_compatibility_cryptfs_scrypt();
 }
 
+#if 0
 /* Create a new keymaster key and store it in this footer */
 static int keymaster_create_key_new(struct crypt_mnt_ftr *ftr)
 {
@@ -390,6 +391,7 @@
     }
     return 0;
 }
+#endif
 
 /* This signs the given object using the keymaster key. */
 static int keymaster_sign_object_new(struct crypt_mnt_ftr *ftr,