aboutsummaryrefslogtreecommitdiffstats
path: root/mmcutils
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2010-11-09 20:03:42 -0800
committerKoushik Dutta <koushd@gmail.com>2010-11-09 20:03:42 -0800
commitfef77c02533ee2e62c6827af5ba3cfcc2bd0e749 (patch)
tree4efd1d775801256e7fb790d4db8eedfd112f9d41 /mmcutils
parent7a77aec36218966e80e99c980dff81331600b92f (diff)
downloadbootable_recovery-fef77c02533ee2e62c6827af5ba3cfcc2bd0e749.zip
bootable_recovery-fef77c02533ee2e62c6827af5ba3cfcc2bd0e749.tar.gz
bootable_recovery-fef77c02533ee2e62c6827af5ba3cfcc2bd0e749.tar.bz2
Changes to support Vision recovery. Fixing up a lot of bugs related to the CodeAurora mmc commit.
Change-Id: I9b71070fe41559a5d93d3c35efc3a511b7088e8e
Diffstat (limited to 'mmcutils')
-rw-r--r--mmcutils/mmcutils.c74
-rw-r--r--mmcutils/mmcutils.h12
2 files changed, 71 insertions, 15 deletions
diff --git a/mmcutils/mmcutils.c b/mmcutils/mmcutils.c
index d7e459a..f7df95d 100644
--- a/mmcutils/mmcutils.c
+++ b/mmcutils/mmcutils.c
@@ -47,16 +47,6 @@ char *ext3_partitions[] = {"system", "userdata", "cache", "NONE"};
unsigned vfat_count = 0;
char *vfat_partitions[] = {"modem", "NONE"};
-struct MmcPartition {
- char *device_index;
- char *filesystem;
- char *name;
- unsigned dstatus;
- unsigned dtype ;
- unsigned dfirstsec;
- unsigned dsize;
-};
-
typedef struct {
MmcPartition *partitions;
int partitions_allocd;
@@ -80,6 +70,10 @@ mmc_partition_name (MmcPartition *mbr, unsigned int type) {
sprintf(name,"boot");
mbr->name = strdup(name);
break;
+ case MMC_RECOVERY_TYPE:
+ sprintf(name,"recovery");
+ mbr->name = strdup(name);
+ break;
case MMC_EXT3_TYPE:
if (strcmp("NONE", ext3_partitions[ext3_count])) {
strcpy((char *)name,(const char *)ext3_partitions[ext3_count]);
@@ -291,9 +285,9 @@ mmc_find_partition_by_name(const char *name)
return NULL;
}
-#define MKE2FS_BIN "/sbin/mke2fs_static"
-#define TUNE2FS_BIN "/sbin/tune2fs_static"
-#define E2FSCK_BIN "/sbin/e2fsck_static"
+#define MKE2FS_BIN "/sbin/mke2fs"
+#define TUNE2FS_BIN "/sbin/tune2fs"
+#define E2FSCK_BIN "/sbin/e2fsck"
static int
run_exec_process ( char **argv) {
@@ -323,7 +317,7 @@ mmc_format_ext3 (MmcPartition *partition) {
return -1;
// Run tune2fs
- char *const tune2fs[] = {TUNE2FS_BIN, "-C", "1", device, NULL};
+ char *const tune2fs[] = {TUNE2FS_BIN, "-j", "-C", "1", device, NULL};
if(run_exec_process(tune2fs))
return -1;
@@ -413,3 +407,55 @@ ERROR3:
}
+
+int
+mmc_raw_dump (const MmcPartition *partition, char *out_file) {
+ int ch;
+ FILE *in;
+ FILE *out;
+ int val = 0;
+ char buf[512];
+ unsigned sz = 0;
+ unsigned i;
+ int ret = -1;
+ char *in_file = partition->device_index;
+
+ in = fopen ( in_file, "r" );
+ if (in == NULL)
+ goto ERROR3;
+
+ out = fopen ( out_file, "w" );
+ if (out == NULL)
+ goto ERROR2;
+
+ fseek(in, 0L, SEEK_END);
+ sz = ftell(in);
+ fseek(in, 0L, SEEK_SET);
+
+ if (sz % 512)
+ {
+ while ( ( ch = fgetc ( in ) ) != EOF )
+ fputc ( ch, out );
+ }
+ else
+ {
+ for (i=0; i< (sz/512); i++)
+ {
+ if ((fread(buf, 512, 1, in)) != 1)
+ goto ERROR1;
+ if ((fwrite(buf, 512, 1, out)) != 1)
+ goto ERROR1;
+ }
+ }
+
+ fsync(out);
+ ret = 0;
+ERROR1:
+ fclose ( out );
+ERROR2:
+ fclose ( in );
+ERROR3:
+ return ret;
+
+}
+
diff --git a/mmcutils/mmcutils.h b/mmcutils/mmcutils.h
index bab494a..6a3070d 100644
--- a/mmcutils/mmcutils.h
+++ b/mmcutils/mmcutils.h
@@ -50,6 +50,7 @@
#define MMC_BOOT_TYPE 0x48
#define MMC_SYSTEM_TYPE 0x82
#define MMC_USERDATA_TYPE 0x83
+#define MMC_RECOVERY_TYPE 0x71
#define MMC_RCA 2
@@ -70,7 +71,15 @@
#define MMC_BOOT_TYPE 0x48
#define MMC_EXT3_TYPE 0x83
#define MMC_VFAT_TYPE 0xC
-typedef struct MmcPartition MmcPartition;
+typedef struct MmcPartition {
+ char *device_index;
+ char *filesystem;
+ char *name;
+ unsigned dstatus;
+ unsigned dtype ;
+ unsigned dfirstsec;
+ unsigned dsize;
+} MmcPartition;
/* Functions */
int mmc_scan_partitions();
@@ -79,6 +88,7 @@ int mmc_format_ext3 (MmcPartition *partition);
int mmc_mount_partition(const MmcPartition *partition, const char *mount_point, \
int read_only);
int mmc_raw_copy (const MmcPartition *partition, char *in_file);
+int mmc_raw_dump (const MmcPartition *partition, char *out_file);
#endif // MMCUTILS_H_