diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:54 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:54 -0800 |
commit | 1b8e5a6b14ca850920e19b3dfae41e6494475c1a (patch) | |
tree | 67bdeb039019f8a47d5cd607c18d99a7c8eb3141 /vold/format.c | |
parent | 13f797da7f190e9ea52f2f3d235210b8a4963b21 (diff) | |
download | system_core-1b8e5a6b14ca850920e19b3dfae41e6494475c1a.zip system_core-1b8e5a6b14ca850920e19b3dfae41e6494475c1a.tar.gz system_core-1b8e5a6b14ca850920e19b3dfae41e6494475c1a.tar.bz2 |
auto import from //branches/cupcake/...@131421
Diffstat (limited to 'vold/format.c')
-rwxr-xr-x | vold/format.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/vold/format.c b/vold/format.c index b413cc7..dd0515c 100755 --- a/vold/format.c +++ b/vold/format.c @@ -27,31 +27,44 @@ #include "logwrapper.h" static char MKDOSFS_PATH[] = "/system/bin/mkdosfs"; +static char MKE2FS_PATH[] = "/system/bin/mke2fs"; -int format_partition(blkdev_t *part) +int format_partition(blkdev_t *part, char *type) { char *devpath; - char *args[7]; + int rc = -EINVAL; devpath = blkdev_get_devpath(part); - args[0] = MKDOSFS_PATH; - args[1] = "-F 32"; - args[2] = "-c 32"; - args[3] = "-n 2"; - args[4] = "-O android"; - args[5] = devpath; - args[6] = NULL; - - int rc = logwrap(6, args); + if (!strcmp(type, FORMAT_TYPE_FAT32)) { + char *args[7]; + args[0] = MKDOSFS_PATH; + args[1] = "-F 32"; + args[2] = "-c 32"; + args[3] = "-n 2"; + args[4] = "-O android"; + args[5] = devpath; + args[6] = NULL; + rc = logwrap(6, args); + } else { + char *args[7]; + args[0] = MKE2FS_PATH; + args[1] = "-b 4096"; + args[2] = "-m 1"; + args[3] = "-L android"; + args[4] = "-v"; + args[5] = devpath; + args[6] = NULL; + rc = logwrap(6, args); + } free(devpath); if (rc == 0) { - LOG_VOL("Filesystem formatted OK\n"); + LOG_VOL("Filesystem formatted OK"); return 0; } else { - LOGE("Format failed (unknokwn exit code %d)\n", rc); + LOGE("Format failed (unknokwn exit code %d)", rc); return -EIO; } return 0; @@ -79,19 +92,19 @@ int initialize_mbr(blkdev_t *disk) dos_partition_enc(block + DOSPARTOFF, &part); if ((fd = open(devpath, O_RDWR)) < 0) { - LOGE("Error opening disk file (%s)\n", strerror(errno)); + LOGE("Error opening disk file (%s)", strerror(errno)); return -errno; } free(devpath); if (write(fd, block, sizeof(block)) < 0) { - LOGE("Error writing MBR (%s)\n", strerror(errno)); + LOGE("Error writing MBR (%s)", strerror(errno)); close(fd); return -errno; } if (ioctl(fd, BLKRRPART, NULL) < 0) { - LOGE("Error re-reading partition table (%s)\n", strerror(errno)); + LOGE("Error re-reading partition table (%s)", strerror(errno)); close(fd); return -errno; } |