summaryrefslogtreecommitdiffstats
path: root/recovery-persist.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-07-20 09:27:35 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-07-20 09:27:35 +0200
commit9030a47ab4ce9369eaeda08eeaad764fcebc8ce4 (patch)
tree38c38831f3a8bff345a92e1e8e85bfa57db480b7 /recovery-persist.cpp
parentrelease-request-05263112-375a-4b1f-a657-a14bb2a5c5a3-for-git_oc-mr1-release-4185249 snap-temp-L63000000082739046 (diff)
parentMerge "Fix the android-cloexec-* warnings in bootable/recovery" am: 94a8ea1797 am: 6d8827e0d3 am: 96b5bb9601 (diff)
downloadandroid_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.tar
android_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.tar.gz
android_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.tar.bz2
android_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.tar.lz
android_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.tar.xz
android_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.tar.zst
android_bootable_recovery-9030a47ab4ce9369eaeda08eeaad764fcebc8ce4.zip
Diffstat (limited to 'recovery-persist.cpp')
-rw-r--r--recovery-persist.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/recovery-persist.cpp b/recovery-persist.cpp
index d706ccac8..dbce7ff74 100644
--- a/recovery-persist.cpp
+++ b/recovery-persist.cpp
@@ -59,21 +59,21 @@ static void check_and_fclose(FILE *fp, const char *name) {
}
static void copy_file(const char* source, const char* destination) {
- FILE* dest_fp = fopen(destination, "w");
- if (dest_fp == nullptr) {
- PLOG(ERROR) << "Can't open " << destination;
- } else {
- FILE* source_fp = fopen(source, "r");
- if (source_fp != nullptr) {
- char buf[4096];
- size_t bytes;
- while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) {
- fwrite(buf, 1, bytes, dest_fp);
- }
- check_and_fclose(source_fp, source);
- }
- check_and_fclose(dest_fp, destination);
+ FILE* dest_fp = fopen(destination, "we");
+ if (dest_fp == nullptr) {
+ PLOG(ERROR) << "Can't open " << destination;
+ } else {
+ FILE* source_fp = fopen(source, "re");
+ if (source_fp != nullptr) {
+ char buf[4096];
+ size_t bytes;
+ while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) {
+ fwrite(buf, 1, bytes, dest_fp);
+ }
+ check_and_fclose(source_fp, source);
}
+ check_and_fclose(dest_fp, destination);
+ }
}
static bool rotated = false;
@@ -120,7 +120,7 @@ int main(int argc, char **argv) {
*/
bool has_cache = false;
static const char mounts_file[] = "/proc/mounts";
- FILE *fp = fopen(mounts_file, "r");
+ FILE* fp = fopen(mounts_file, "re");
if (!fp) {
PLOG(ERROR) << "failed to open " << mounts_file;
} else {