libsnapshot: write files atomically

... by writing to a temporary file then rename()'ing it
back.

Test: libsnapshot_test
Bug: 144549076
Change-Id: Ide400aff8d67d56d422d0adea3a4f1673ebc9994
3 files changed