Skip to content

Commit

Permalink
encore: fix accidental formatting of /boot partition
Browse files Browse the repository at this point in the history
When emmc and sdcard share device major number, vold can pick
the wrong device based on partion nodes alone. This adds an override
to use device node mapping instead.

Change-Id: Icb9b301c278656631aa9db5c2ca09b11da870794
  • Loading branch information
TwidgeVR committed Mar 4, 2011
1 parent 708e884 commit bc4054f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Android.mk
Expand Up @@ -55,6 +55,10 @@ ifneq ($(BOARD_VOLD_MAX_PARTITIONS),)
LOCAL_CFLAGS += -DVOLD_MAX_PARTITIONS=$(BOARD_VOLD_MAX_PARTITIONS)
endif

ifeq ($(BOARD_VOLD_EMMC_SHARES_DEV_MAJOR), true)
LOCAL_CFLAGS += -DVOLD_EMMC_SHARES_DEV_MAJOR
endif

ifneq ($(TARGET_USE_CUSTOM_LUN_FILE_PATH),)
LOCAL_CFLAGS += -DCUSTOM_LUN_FILE=\"$(TARGET_USE_CUSTOM_LUN_FILE_PATH)\"
endif
Expand Down
9 changes: 9 additions & 0 deletions Volume.cpp
Expand Up @@ -233,6 +233,15 @@ int Volume::formatVol() {
sprintf(devicePath, "/dev/block/vold/%d:%d",
MAJOR(partNode), MINOR(partNode));

#ifdef VOLD_EMMC_SHARES_DEV_MAJOR
// If emmc and sdcard share dev major number, vold may pick
// incorrectly based on partition nodes alone, formatting
// the wrong device. Use device nodes instead.
dev_t deviceNodes;
getDeviceNodes((dev_t *) &deviceNodes, 1);
sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(deviceNodes), MINOR(deviceNodes));
#endif

if (mDebug) {
SLOGI("Formatting volume %s (%s)", getLabel(), devicePath);
}
Expand Down

0 comments on commit bc4054f

Please sign in to comment.