writeDataAtomic() fixes (#140)
writeDataAtomic() fixes (#140)

* filesystem: ensure data is persisted before returning success

Sync the temporary file before renaming it, to ensure that after a
crash, the destination file isn't zero-length or otherwise incomplete.

Also sync the directory after the rename, to ensure the rename has been
persisted before returning success.

* filesystem: don't use fixed temporary file name

Using a fixed temporary file name in a world-writable sticky directory
is problematic since another user can create the file first.

Use ioutil.TempFile() to do it properly.  It uses O_EXCL under the hood
to ensure the file is newly created.

google/fscrypt,google/fscrypt,google/fscrypt