diff options
author | Yifan Hong <elsk@google.com> | 2019-11-26 16:07:04 -0800 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2019-12-04 14:49:47 -0800 |
commit | b6663cfb5a459b7c70212ed9b79ac8a93e152995 (patch) | |
tree | afe808e2374161962e969be02d58a174a806870b /libutils/ProcessCallStack_fuzz.cpp | |
parent | 3a8001476d23953ade281d401ff515df530b2b32 (diff) |
libsnapshot: lock on /metadata/ota
We used to flock() on /metadata/ota/state to ensure
atomic access. However, writing the file itself is
not necessary atomic and may lead to inconsistent
states.
This change redirects flock() to the outer directory, /metadata/ota,
which is very likely to exist (see exception below).
flock() is called on this directory instead of /state. This allows
a follow-up change to turn all writes to the /metadata partition
atomic.
Note: /metadata/ota may not exist during first boot after a flash
with wipe. However, first_stage_init always checks existence of
boot indicator before even trying to flock() (via
IsSnapshotManagerNeeded() and NeedSnapshotsInFirstStageMount()). If
the boot indicator exists, /metadata/ota must exist as well.
Also add tests to ensure LockExclusive() and LockShared() works as
expected.
Test: libsnapshot_test
Test: apply OTA from older build to this, then reboot
Bug: 144549076
Change-Id: Ib4dd9e9be1a43013c328e181b9398ac0b514dbce
Diffstat (limited to 'libutils/ProcessCallStack_fuzz.cpp')
0 files changed, 0 insertions, 0 deletions