From 6244806a628a24e95e389616aa849d96e1010e62 Mon Sep 17 00:00:00 2001 From: Matt Mower Date: Sun, 12 Feb 2017 15:13:00 -0600 Subject: Fix bldr msg file open mode when offset specified It was pointed out to me by gmrt that O_APPEND is incorrect, as lseek before writing would be undone (perhaps we avoided this issue due to an inability to write beyond the end of a partition) and O_RDWR is not necessary to lseek. When AOSP switched from fopen to open, they also removed the full partition wipe (fopen in wb mode) before each write, so this is no longer an issue. Completely restore the original AOSP file access mode flags. Change-Id: I42b4efc5f499360ce5b761d3a2a5d4dac4cdfb65 --- bootloader_message/bootloader_message.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index 449f40e11..4d1ce5bb4 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -159,10 +159,7 @@ static bool write_misc_partition(const void* p, size_t size, size_t offset, std: *err = "no misc device set"; return false; } - int open_flags = O_WRONLY | O_SYNC; - if (offset > 0) - open_flags = O_RDWR | O_APPEND | O_SYNC; - int fd = (open(misc_blk_device.c_str(), open_flags)); + int fd = (open(misc_blk_device.c_str(), O_WRONLY | O_SYNC)); if (fd == -1) { *err = "failed to open " + misc_blk_device + ": "; *err += strerror(errno); -- cgit v1.2.3