Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
5f05ac7
recovery: Fix adb backup
ThiagoVinicius May 19, 2013
9de39c1
Remove (un)mount option for datamedia partitions
mdmower May 24, 2013
2162ee6
Fix compiler warning: redefinition in extendedcommands.c
mdmower May 24, 2013
cc5591a
support version 2 (2048-bit e=65537) keys in recovery
Jul 25, 2012
a8a1ac7
Merge "recovery: Fix adb backup" into cm-10.1
koush Jun 3, 2013
f5cb73e
Merge "Remove (un)mount option for datamedia partitions" into cm-10.1
gweedo767 Jun 5, 2013
ed53bd0
Merge "Fix compiler warning: redefinition in extendedcommands.c" into…
gweedo767 Jun 7, 2013
e672fdf
move "install zip from sideload" to installation submenu
jt1134 Oct 26, 2012
71d76c2
Fix the potential segmentation fault
Jun 4, 2013
7ac751f
recovery: use just the mount point instead of the full path
turl Jun 8, 2013
51eb3cf
Merge "recovery: use just the mount point instead of the full path" i…
koush Jun 8, 2013
593b54c
fix stat usage
koush Jun 19, 2013
a1d5819
Fix usage of stat vs statfs
koush Jun 8, 2013
f572459
Bump to 6.0.3.3
gweedo767 Jul 1, 2013
cfb115f
Update for zlib changes
arco May 17, 2013
64615ee
SELinux: don't suppress the "no file_contexts" message on the UI
chirayudesai Jul 18, 2013
ab60a07
add --headless mode
koush Jul 19, 2013
38a4356
Merge "add --headless mode" into cm-10.1
koush Jul 19, 2013
a81817c
more headless fixes
koush Jul 23, 2013
8736cc1
Remove "fix permissions" option
mikeNG Jul 23, 2013
b9ecf64
Add power off & reboot to bootloader mode in advanced menu
mikeNG Jul 12, 2013
f427a7d
cwm: Add liblog dependency
rmcc Jul 25, 2013
62c6902
Add a recovery version variable
rmcc Jul 26, 2013
1a6c91f
Use fstab v1 as a default.
rmcc Jul 26, 2013
96d9f22
Remove "fix permissions" option
mikeNG Jul 23, 2013
05ad6a1
Add power off & reboot to bootloader mode in advanced menu
mikeNG Jul 12, 2013
d56d0fd
Fixes for Superuser
koush Jul 28, 2013
ebecbc6
Fixes for Superuser
koush Jul 28, 2013
912b6d9
su installation and detection updates for 4.3
koush Jul 30, 2013
ab6769d
6035
koush Jul 30, 2013
a2aac83
add su daemon runner
koush Jul 30, 2013
bf44d1e
Merge remote-tracking branch 'github/cm-10.1' into cm-10.2
koush Jul 30, 2013
04f02c5
4.3 detection fix
koush Jul 30, 2013
ab43813
Merge remote-tracking branch 'github/cm-10.1' into cm-10.2
koush Jul 30, 2013
37566e2
unset immutable bit on install-recovery.sh
koush Jul 31, 2013
00857c9
Don't treat link-time warnings as errors when linking with libbusybox
steven676 Jul 31, 2013
8b26c06
Fix roots.c to use fs_mgr
koush Aug 1, 2013
d9b4033
move key loading to verifier code
Nov 2, 2012
2ad4587
recovery: save logs from the last few invocations of recovery
May 16, 2013
4dc0a95
Revert "Use fstab v1 as a default."
chirayudesai Aug 4, 2013
c70c202
recovery: ignore voldmanaged volumes
pawitp Aug 3, 2013
935a504
Update wipe data option confirmation
mikeNG Jul 12, 2013
7e87f26
Add sdparted option to partition in ext4 fstype
PhilZ-cwm6 Jun 12, 2013
fce3e08
Merge "Revert "Use fstab v1 as a default."" into cm-10.2
koush Aug 5, 2013
cb9b7a6
Merge "Add sdparted option to partition in ext4 fstype" into cm-10.2
koush Aug 6, 2013
985324f
unlink() equals remove() in this situation can cause data loss and fi…
PhilZ-cwm6 Aug 6, 2013
3860331
fix stat for correct free space when backup path is second storage
PhilZ-cwm6 Aug 9, 2013
0c328c7
Shrink cid
koush Aug 13, 2013
e19f1d8
v6036
koush Aug 13, 2013
6bdc5c6
Enable mount usb for external storage on datamedia devices
PhilZ-cwm6 Aug 14, 2013
5a650a9
Fix issue where android device manager, etc, dont actually wipe data.
koush Aug 16, 2013
6830848
Merge "fix stat for correct free space when backup path is second sto…
koush Aug 16, 2013
c0cab40
Merge "Enable mount usb for external storage on datamedia devices" in…
koush Aug 16, 2013
ead73d8
Merge "Fix issue where android device manager, etc, dont actually wip…
koush Aug 16, 2013
aee5f78
If sd-ext is defined in recovery.fstab, but user did not partition sd…
PhilZ-cwm6 Aug 16, 2013
03667f6
recovery: Only install adb keys once
hyperb1iss Aug 18, 2013
efa3b63
recovery: Revenge of MiniVold
hyperb1iss Aug 17, 2013
ad054c6
recovery: Don't enable UMS function unless needed
hyperb1iss Aug 24, 2013
a0591d6
recovery: Don't automount external storage at startup
hyperb1iss Aug 24, 2013
d30168d
recovery: Add sdcard daemon
hyperb1iss Aug 24, 2013
97451a7
recovery: try to write EMMC partitions more reliably
Jul 8, 2013
5b331f8
recovery: write partitions more conservatively
Jul 9, 2013
a4b5d55
recovery: sleep after writing partition and closing it
Jul 10, 2013
fa9a990
recovery: Support for compressed backups
hyperb1iss Aug 24, 2013
7c576cf
recovery: all vold loglines deserve newlines
mdmower Aug 24, 2013
f0bd6bf
recovery: close zip archive after installation
pawitp Aug 25, 2013
0005c1e
recovery: Cleanups
hyperb1iss Aug 24, 2013
f22626c
recovery: only use vold format for exact path match
pawitp Aug 26, 2013
a8ed457
recovery: don't overallocate for get_android_secure_path
pawitp Aug 26, 2013
ca02861
recovery: fix --update_package using legacy path
pawitp Aug 26, 2013
f13325d
Merge "recovery: fix --update_package using legacy path" into cm-10.2
rmcc Aug 26, 2013
ea09a67
Revert "recovery: fix --update_package using legacy path"
pawitp Aug 26, 2013
efa6d29
Merge "Revert "recovery: fix --update_package using legacy path"" int…
pawitp Aug 26, 2013
a867f0e
recovery: Don't link with minivold
hyperb1iss Aug 27, 2013
83e26bf
Revert "Revert "recovery: fix --update_package using legacy path""
pawitp Aug 27, 2013
9046cda
Recovery: Loki patching support
Shelnutt2 Jul 20, 2013
7cc6afa
Don't print any messages regarding sd-ext to the UI
chirayudesai Sep 8, 2013
bfb14d1
Merge "Recovery: Loki patching support" into cm-10.2
rmcc Sep 10, 2013
ecd5053
Add required libraries to list.
maniac103 Sep 23, 2013
619fbec
Version bump to 6.0.2.8
gweedo767 Sep 24, 2013
fd6b35c
Support f2fs format
Aug 28, 2013
7889b76
Bump to 6.0.3.9
gweedo767 Sep 30, 2013
a638264
recovery: support format external storage to custom fstype using vold
PhilZ-cwm6 Sep 5, 2013
80a3625
Make updating Advanced Menu a simpler task
PhilZ-cwm6 Sep 8, 2013
e506d5b
Fix refresh usb devices when key repeat is enabled
PhilZ-cwm6 Sep 18, 2013
684696c
Fix extract of tgz multi volumes corruption at split point
PhilZ-cwm6 Sep 16, 2013
af5f065
"not enough rainbows, 1 star uninstall"
cennis91 May 2, 2013
ed4b49f
fix f2fs formatting from edify scripting
PhilZ-cwm6 Sep 27, 2013
388b651
6040
koush Oct 2, 2013
2620558
Allow sideload to be used in conjunction with other commands.
koush Oct 5, 2013
00f56a4
6.0.4.2
koush Oct 6, 2013
9a786a7
6.0.4.3
koush Oct 6, 2013
0624f20
Update events.c
jeboo Oct 6, 2013
8efc113
loki: Update to 2.0, Add support for LG G2 (and device trees in general)
djrbliss Oct 7, 2013
6603219
6.0.4.4
koush Oct 8, 2013
fbdc080
Merge "Add required libraries to list." into cm-10.2
maniac103 Oct 10, 2013
3144dc2
Make "one confirm" the default action. Create .many_confirm to restore
gweedo767 Oct 12, 2013
358d4f0
Enable optional swipe based touch controls
gweedo767 Oct 12, 2013
cd35208
always do a clean reboot
PhilZ-cwm6 Oct 14, 2013
f4c69bf
fix the following bugs to better handle new vold code
PhilZ-cwm6 Oct 2, 2013
b33e2c2
Do not log to screen when mounting/unmounting sdcards.
PhilZ-cwm6 Oct 17, 2013
8eeed5f
friendly write_recovery_version()
PhilZ-cwm6 Oct 12, 2013
b745eda
One less integer
PhilZ-cwm6 Oct 19, 2013
48ccdce
minui: Match API to AOSP
hyperb1iss Oct 20, 2013
388e6a7
Add guard makefile for allowing simple recovery build
hyperb1iss Oct 22, 2013
2457cc0
Revert "minui: Match API to AOSP"
hyperb1iss Oct 22, 2013
110942f
Prevent scroll drifting in swipe recovery
gweedo767 Oct 22, 2013
0929066
minui: Allow devices to blank/unblank using LCD backlight
intervigilium Oct 22, 2013
80b7826
Merge "minui: Allow devices to blank/unblank using LCD backlight" int…
rmcc Oct 24, 2013
16faa40
recovery: Add a proper CleanSpec.mk
hyperb1iss Oct 26, 2013
652ef0b
recovery: Clean ALL the things
hyperb1iss Oct 27, 2013
67d5c22
Revert "Revert "minui: Match API to AOSP""
rmcc Nov 5, 2013
00492db
updater: introduce and set_metadata and set_metadata_recursive
nickkral Sep 7, 2013
fc3dd71
Don't apply permission changes to symlink.
nickkral Sep 10, 2013
232abdd
4.4 compatibility
rmcc Nov 5, 2013
8c0c080
verifier: update to support certificates using SHA-256
Apr 10, 2013
e0a9047
start healthd in recovery
toddpoynor Jun 4, 2013
5544cbb
recovery: copy logs to cache more aggressively
Jul 2, 2013
68edaf7
recovery: preserve recovery logs across cache wipes
Jul 9, 2013
d411cba
fix secure adb in recovery
Sep 11, 2013
c272b56
Merge git@github.com:CyanogenMod/android_bootable_recovery.git into …
sndnvaps Nov 10, 2013
f2f397f
fix merge conflict
sndnvaps Nov 11, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ifneq ($(WITH_SIMPLE_RECOVERY),true)

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

Expand All @@ -13,14 +15,16 @@ LOCAL_SRC_FILES := \
mounts.c \
extendedcommands.c \
nandroid.c \
../../system/core/toolbox/reboot.c \
reboot.c \
../../system/core/toolbox/dynarray.c \
../../system/core/toolbox/newfs_msdos.c \
firmware.c \
edifyscripting.c \
prop.c \
default_recovery_ui.c \
adb_install.c \
verifier.c
verifier.c \
../../system/vold/vdc.c

ADDITIONAL_RECOVERY_FILES := $(shell echo $$ADDITIONAL_RECOVERY_FILES)
LOCAL_SRC_FILES += $(ADDITIONAL_RECOVERY_FILES)
Expand All @@ -29,6 +33,8 @@ LOCAL_MODULE := recovery

LOCAL_FORCE_STATIC_EXECUTABLE := true

RECOVERY_FSTAB_VERSION := 2

ifdef I_AM_KOUSH
RECOVERY_NAME := ClockworkMod Recovery
LOCAL_CFLAGS += -DI_AM_KOUSH
Expand All @@ -38,7 +44,7 @@ RECOVERY_NAME := CWM-based Recovery
endif
endif

RECOVERY_VERSION := $(RECOVERY_NAME) v6.0.3.2
RECOVERY_VERSION := $(RECOVERY_NAME) v6.0.4.4

LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
Expand All @@ -54,12 +60,18 @@ ifeq ($(BOARD_USE_CUSTOM_RECOVERY_FONT),)
BOARD_USE_CUSTOM_RECOVERY_FONT := \"font_10x18.h\"
endif

ifeq ($(ENABLE_LOKI_RECOVERY),true)
LOCAL_CFLAGS += -DENABLE_LOKI
LOCAL_SRC_FILES += \
compact_loki.c
endif

BOARD_RECOVERY_CHAR_WIDTH := $(shell echo $(BOARD_USE_CUSTOM_RECOVERY_FONT) | cut -d _ -f 2 | cut -d . -f 1 | cut -d x -f 1)
BOARD_RECOVERY_CHAR_HEIGHT := $(shell echo $(BOARD_USE_CUSTOM_RECOVERY_FONT) | cut -d _ -f 2 | cut -d . -f 1 | cut -d x -f 2)

LOCAL_CFLAGS += -DBOARD_RECOVERY_CHAR_WIDTH=$(BOARD_RECOVERY_CHAR_WIDTH) -DBOARD_RECOVERY_CHAR_HEIGHT=$(BOARD_RECOVERY_CHAR_HEIGHT)

BOARD_RECOVERY_DEFINES := BOARD_HAS_NO_SELECT_BUTTON BOARD_UMS_LUNFILE BOARD_RECOVERY_ALWAYS_WIPES BOARD_RECOVERY_HANDLES_MOUNT BOARD_TOUCH_RECOVERY RECOVERY_EXTEND_NANDROID_MENU TARGET_USE_CUSTOM_LUN_FILE_PATH TARGET_DEVICE
BOARD_RECOVERY_DEFINES := BOARD_RECOVERY_SWIPE BOARD_HAS_NO_SELECT_BUTTON BOARD_UMS_LUNFILE BOARD_RECOVERY_ALWAYS_WIPES BOARD_RECOVERY_HANDLES_MOUNT BOARD_TOUCH_RECOVERY RECOVERY_EXTEND_NANDROID_MENU TARGET_USE_CUSTOM_LUN_FILE_PATH TARGET_DEVICE TARGET_RECOVERY_FSTAB

$(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
$(if $($(board_define)), \
Expand All @@ -69,8 +81,10 @@ $(foreach board_define,$(BOARD_RECOVERY_DEFINES), \

LOCAL_STATIC_LIBRARIES :=

LOCAL_CFLAGS += -DUSE_EXT4
LOCAL_C_INCLUDES += system/extras/ext4_utils
LOCAL_CFLAGS += -DUSE_EXT4 -DMINIVOLD
LOCAL_C_INCLUDES += system/extras/ext4_utils system/core/fs_mgr/include external/fsck_msdos
LOCAL_C_INCLUDES += system/vold

LOCAL_STATIC_LIBRARIES += libext4_utils_static libz libsparse_static

# This binary is in the recovery ramdisk, which is otherwise a copy of root.
Expand All @@ -86,27 +100,37 @@ else
LOCAL_SRC_FILES += $(BOARD_CUSTOM_RECOVERY_KEYMAPPING)
endif

LOCAL_STATIC_LIBRARIES += libvoldclient libsdcard libminipigz libfsck_msdos
LOCAL_STATIC_LIBRARIES += libmake_ext4fs libext4_utils_static libz libsparse_static

ifeq ($(TARGET_USERIMAGES_USE_F2FS), true)
LOCAL_CFLAGS += -DUSE_F2FS
LOCAL_STATIC_LIBRARIES += libmake_f2fs libfsck_f2fs libfibmap_f2fs
endif

LOCAL_STATIC_LIBRARIES += libminzip libunz libmincrypt

LOCAL_STATIC_LIBRARIES += libminizip libminadbd libedify libbusybox libmkyaffs2image libunyaffs liberase_image libdump_image libflash_image
LOCAL_LDFLAGS += -Wl,--no-fatal-warnings

LOCAL_STATIC_LIBRARIES += libdedupe libcrypto_static libcrecovery libflashutils libmtdutils libmmcutils libbmlutils
LOCAL_STATIC_LIBRARIES += libfs_mgr libdedupe libcrypto_static libcrecovery libflashutils libmtdutils libmmcutils libbmlutils

ifeq ($(BOARD_USES_BML_OVER_MTD),true)
LOCAL_STATIC_LIBRARIES += libbml_over_mtd
endif

LOCAL_STATIC_LIBRARIES += libminui libpixelflinger_static libpng libcutils
LOCAL_STATIC_LIBRARIES += libminui libpixelflinger_static libpng libcutils liblog
LOCAL_STATIC_LIBRARIES += libstdc++ libc

LOCAL_STATIC_LIBRARIES += libselinux

LOCAL_C_INCLUDES += system/extras/ext4_utils

include $(BUILD_EXECUTABLE)

RECOVERY_LINKS := bu make_ext4fs edify busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid reboot volume setprop getprop dedupe minizip
RECOVERY_LINKS := bu make_ext4fs edify busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid reboot volume setprop getprop start stop dedupe minizip setup_adbd fsck_msdos newfs_msdos vdc sdcard pigz

ifeq ($(TARGET_USERIMAGES_USE_F2FS), true)
RECOVERY_LINKS += mkfs.f2fs fsck.f2fs fibmap.f2fs
endif

# nc is provided by external/netcat
RECOVERY_SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(RECOVERY_LINKS))
Expand Down Expand Up @@ -152,6 +176,8 @@ include $(CLEAR_VARS)

LOCAL_SRC_FILES := verifier_test.c verifier.c

LOCAL_C_INCLUDES += system/extras/ext4_utils system/core/fs_mgr/include

LOCAL_MODULE := verifier_test

LOCAL_FORCE_STATIC_EXECUTABLE := true
Expand All @@ -178,4 +204,7 @@ include $(commands_recovery_local_path)/updater/Android.mk
include $(commands_recovery_local_path)/applypatch/Android.mk
include $(commands_recovery_local_path)/utilities/Android.mk
include $(commands_recovery_local_path)/su/Android.mk
include $(commands_recovery_local_path)/voldclient/Android.mk
commands_recovery_local_path :=

endif
30 changes: 30 additions & 0 deletions CleanSpec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,33 @@
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/recovery_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/dump_image_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/flash_image_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/erase_image_intermediates)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libflashutils_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libmmcutils_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libmtdutils_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbmlutils_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libcrecovery_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libvoldclient_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libminui_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libdedupe_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libedify_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libdump_image_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/liberase_image_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libflash_image_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libminizip_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libminadbd_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libmkyaffs2image_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libunyaffs_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libminelf_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libbml_over_mtd_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libmake_ext4fs_intermediates)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libminui_intermediates)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/RECOVERY_EXECUTABLES)

$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/updater_intermediates)
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
merge git@github.com:CyanogenMod/android_bootable_recovery.git cm-11.0 branch

bunch version to 6.0.4.4

# sndnvaps <sndnvaps@gmail.com>
16 changes: 13 additions & 3 deletions adb_install.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ void *adb_sideload_thread(void* v) {

int
apply_from_adb() {

#ifdef ENABLE_LOKI
int loki_support;
#endif
stop_adbd();
set_usb_driver(1);

Expand All @@ -115,7 +117,7 @@ apply_from_adb() {
pthread_t sideload_thread;
pthread_create(&sideload_thread, NULL, &adb_sideload_thread, &data);

static char* headers[] = { "ADB Sideload",
static const char* headers[] = { "ADB Sideload",
"",
NULL
};
Expand Down Expand Up @@ -153,6 +155,14 @@ apply_from_adb() {
}

remove(ADB_SIDELOAD_FILENAME);

#ifdef ENABLE_LOKI
if(loki_support_enabled) {
ui_print("Checking if loki-fying is needed");
int result;
if(result = loki_check()) {
return result;
}
}
#endif
return install_status;
}
109 changes: 101 additions & 8 deletions applypatch/applypatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int LoadFileContents(const char* filename, FileContents* file,
}
}

SHA(file->data, file->size, file->sha1);
SHA_hash(file->data, file->size, file->sha1);
return 0;
}

Expand Down Expand Up @@ -421,18 +421,111 @@ int WriteToPartition(unsigned char* data, size_t len,
break;

case EMMC:
;
FILE* f = fopen(partition, "wb");
if (fwrite(data, 1, len, f) != len) {
printf("short write writing to %s (%s)\n",
partition, strerror(errno));
{
size_t start = 0;
int success = 0;
int fd = open(partition, O_RDWR);
if (fd < 0) {
printf("failed to open %s: %s\n", partition, strerror(errno));
return -1;
}
if (fclose(f) != 0) {
int attempt;

for (attempt = 0; attempt < 10; ++attempt) {
size_t next_sync = start + (1<<20);
printf("raw write %s attempt %d start at %d\n", partition, attempt+1, start);
lseek(fd, start, SEEK_SET);
while (start < len) {
size_t to_write = len - start;
if (to_write > 4096) to_write = 4096;

ssize_t written = write(fd, data+start, to_write);
if (written < 0) {
if (errno == EINTR) {
written = 0;
} else {
printf("failed write writing to %s (%s)\n",
partition, strerror(errno));
return -1;
}
}
start += written;
if (start >= next_sync) {
fsync(fd);
next_sync = start + (1<<20);
}
}
fsync(fd);

// drop caches so our subsequent verification read
// won't just be reading the cache.
sync();
int dc = open("/proc/sys/vm/drop_caches", O_WRONLY);
write(dc, "3\n", 2);
close(dc);
sleep(1);
printf(" caches dropped\n");

// verify
lseek(fd, 0, SEEK_SET);
unsigned char buffer[4096];
start = len;
size_t p;
for (p = 0; p < len; p += sizeof(buffer)) {
size_t to_read = len - p;
if (to_read > sizeof(buffer)) to_read = sizeof(buffer);

size_t so_far = 0;
while (so_far < to_read) {
ssize_t read_count = read(fd, buffer+so_far, to_read-so_far);
if (read_count < 0) {
if (errno == EINTR) {
read_count = 0;
} else {
printf("verify read error %s at %d: %s\n",
partition, p, strerror(errno));
return -1;
}
}
if ((size_t)read_count < to_read) {
printf("short verify read %s at %d: %d %d %s\n",
partition, p, read_count, to_read, strerror(errno));
}
so_far += read_count;
}

if (memcmp(buffer, data+p, to_read)) {
printf("verification failed starting at %d\n", p);
start = p;
break;
}
}

if (start == len) {
printf("verification read succeeded (attempt %d)\n", attempt+1);
success = true;
break;
}

sleep(2);
}

if (!success) {
printf("failed to verify after all attempts\n");
return -1;
}

if (close(fd) != 0) {
printf("error closing %s (%s)\n", partition, strerror(errno));
return -1;
}
// hack: sync and sleep after closing in hopes of getting
// the data actually onto flash.
printf("sleeping after close\n");
sync();
sleep(5);
break;
}
}

free(copy);
Expand Down Expand Up @@ -473,7 +566,7 @@ int ParseSha1(const char* str, uint8_t* digest) {
// Search an array of sha1 strings for one matching the given sha1.
// Return the index of the match on success, or -1 if no match is
// found.
int FindMatchingPatch(uint8_t* sha1, const char** patch_sha1_str,
int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str,
int num_patches) {
int i;
uint8_t patch_sha1[SHA_DIGEST_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion applypatch/applypatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int LoadFileContents(const char* filename, FileContents* file,
int retouch_flag);
int SaveFileContents(const char* filename, const FileContents* file);
void FreeFileContents(FileContents* file);
int FindMatchingPatch(uint8_t* sha1, const char** patch_sha1_str,
int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str,
int num_patches);

// bsdiff.c
Expand Down
7 changes: 3 additions & 4 deletions bmlutils/bmlutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int cmd_bml_restore_raw_partition(const char *partition, const char *filename)

int cmd_bml_backup_raw_partition(const char *partition, const char *out_file)
{
char* bml;
const char* bml;
if (strcmp("boot", partition) == 0)
bml = BOARD_BML_BOOT;
else if (strcmp("recovery", partition) == 0)
Expand All @@ -112,9 +112,8 @@ int cmd_bml_backup_raw_partition(const char *partition, const char *out_file)
unsigned sz = 0;
unsigned i;
int ret = -1;
char *in_file = bml;

in = fopen ( in_file, "r" );
in = fopen ( bml, "r" );
if (in == NULL)
goto ERROR3;

Expand Down Expand Up @@ -142,7 +141,7 @@ int cmd_bml_backup_raw_partition(const char *partition, const char *out_file)
}
}

fsync(out);
fsync(fileno(out));
ret = 0;
ERROR1:
fclose ( out );
Expand Down
Loading