ScopedFlock: Refactor it to be a subclass of FdFile.
Makes callers cleaner, since they only have to worry about
dealing with regular File objects that they know will be locked
for the duration of their existence. Prevents issues and other
clunky code relating to acquire
Test: scoped_flock_test, test_art_host
Bug: 36369345
Change-Id: I2c9644e448acde6ddac472d88108c7d9a4e1a892
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index ec3481b..848eb8d 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -304,8 +304,10 @@
TimingLogger::ScopedTiming t("Writing image File", timings_);
std::string error_msg;
- ScopedFlock img_flock;
- img_flock.Init(out, &error_msg);
+ // No error checking here, this is best effort. The locking may or may not
+ // succeed and we don't really care either way.
+ ScopedFlock img_flock = LockedFile::DupOf(out->Fd(), out->GetPath(),
+ true /* read_only_mode */, &error_msg);
CHECK(image_ != nullptr);
CHECK(out != nullptr);