Skip to content
Browse files

Merge branch 'cyanogen' into gingerbread (bmlutils)

Conflicts:
	extendedcommands.c
	utilities/Android.mk
  • Loading branch information...
2 parents af07538 + 88a233d commit f0f0854dcb523be459a421f493678664e04e2c8e @tpruvot committed Nov 13, 2011
Showing with 64 additions and 3 deletions.
  1. +35 −3 bmlutils/bmlutils.c
  2. +6 −0 bmlutils/bmlutils.h
  3. +13 −0 extendedcommands.c
  4. +10 −0 utilities/Android.mk
  5. BIN utilities/fat.format
View
38 bmlutils/bmlutils.c
@@ -21,7 +21,7 @@
#include <sys/wait.h>
extern int __system(const char *command);
-#define BML_UNLOCK_ALL 0x8A29 ///< unlock all partition RO -> RW
+#define BML_UNLOCK_ALL 0x8A29 ///< unlock all partition RO -> RW
#ifndef BOARD_BML_BOOT
#define BOARD_BML_BOOT "/dev/block/bml7"
@@ -56,10 +56,10 @@ static int restore_internal(const char* bml, const char* filename)
if (write(dstfd, buf, 4096) < 4096)
return 5;
} while(bytes_read == 4096);
-
+
close(dstfd);
close(srcfd);
-
+
return 0;
}
@@ -171,3 +171,35 @@ int cmd_bml_get_partition_device(const char *partition, char *device)
{
return -1;
}
+
+int format_rfs_device (const char *device, const char *path) {
+ const char *fatsize = "32";
+ const char *sectorsize = "1";
+
+ if (strcmp(path, "/datadata") == 0 || strcmp(path, "/cache") == 0) {
+ fatsize = "16";
+ }
+
+ // Just in case /data sector size needs to be altered
+ else if (strcmp(path, "/data") == 0 ) {
+ sectorsize = "1";
+ }
+
+ // dump 10KB of zeros to partition before format due to fat.format bug
+ char cmd[PATH_MAX];
+
+ sprintf(cmd, "/sbin/dd if=/dev/zero of=%s bs=4096 count=10", device);
+ if(__system(cmd)) {
+ printf("failure while zeroing rfs partition.\n");
+ return -1;
+ }
+
+ // Run fat.format
+ sprintf(cmd, "/sbin/fat.format -F %s -S 4096 -s %s %s", fatsize, sectorsize, device);
+ if(__system(cmd)) {
+ printf("failure while running fat.format\n");
+ return -1;
+ }
+
+ return 0;
+}
View
6 bmlutils/bmlutils.h
@@ -0,0 +1,6 @@
+#ifndef BMLUTILS_H_
+#define BMLUTILS_H_
+
+int format_rfs_device (const char *device, const char *path);
+
+#endif // BMLUTILS_H_
View
13 extendedcommands.c
@@ -39,6 +39,7 @@
#include "mtdutils/mtdutils.h"
#include "mmcutils/mmcutils.h"
#include "make_ext4fs.h"
+#include "bmlutils/bmlutils.h"
#include EXPAND(BUILD_TOP/external/yaffs2/yaffs2/utils/mkyaffs2image.h)
#include EXPAND(BUILD_TOP/external/yaffs2/yaffs2/utils/unyaffs.h)
@@ -456,6 +457,18 @@ int format_device(const char *device, const char *path, const char *fs_type) {
return -1;
}
+ if (strcmp(fs_type, "rfs") == 0) {
+ if (ensure_path_unmounted(path) != 0) {
+ LOGE("format_volume failed to unmount \"%s\"\n", v->mount_point);
+ return -1;
+ }
+ if (0 != format_rfs_device(device, path)) {
+ LOGE("format_volume: format_rfs_device failed on %s\n", device);
+ return -1;
+ }
+ return 0;
+ }
+
if (strcmp(v->mount_point, path) != 0) {
return format_unknown_device(v->device, path, NULL);
}
View
10 utilities/Android.mk
@@ -58,5 +58,15 @@ else
LOCAL_SRC_FILES := ../../../$(BOARD_MKE2FS)
endif
include $(BUILD_PREBUILT)
+endif
+BOARD_RECOVERY_RFS_CHECK := $(shell grep rfs $(TARGET_DEVICE_DIR)/recovery.fstab)
+ifneq ($(BOARD_RECOVERY_RFS_CHECK),)
+include $(CLEAR_VARS)
+LOCAL_MODULE := fat.format
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+include $(BUILD_PREBUILT)
endif
View
BIN utilities/fat.format
Binary file not shown.

0 comments on commit f0f0854

Please sign in to comment.
Something went wrong with that request. Please try again.