Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d91ffdc authored by Matt Mower's avatar Matt Mower Committed by Dan Pasanen
Browse files

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
(cherry picked from commit 54886fbd)
parent 699573a9
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -113,10 +113,7 @@ static bool write_misc_partition(const void* p, size_t size, size_t offset, std:
  if (misc_blk_device.empty()) {
    return false;
  }
  int open_flags = O_WRONLY | O_SYNC;
  if (offset > 0)
    open_flags = O_RDWR | O_APPEND | O_SYNC;
  android::base::unique_fd fd(open(misc_blk_device.c_str(), open_flags));
  android::base::unique_fd fd(open(misc_blk_device.c_str(), O_WRONLY | O_SYNC));
  if (fd.get() == -1) {
    *err = android::base::StringPrintf("failed to open %s: %s", misc_blk_device.c_str(),
                                       strerror(errno));