OSDN Git Service

Add syncs when creating parent directories
authorEric Biggers <ebiggers@google.com>
Tue, 16 Feb 2021 23:59:17 +0000 (15:59 -0800)
committerEric Biggers <ebiggers@google.com>
Wed, 17 Feb 2021 00:18:53 +0000 (16:18 -0800)
commitfec0c0e47233d57996a37c92fa3e227e67e79465
treea6949f28139885ee86e777beb258c14c8df41e0b
parent3345a2a98c2867bb8c34b8a22a6cd2a1d35aeea8
Add syncs when creating parent directories

vold creates some directories for storing encryption keys if they don't
already exist, potentially including parent directories:

    /metadata/vold/metadata_encryption
    /data/misc/vold/volume_keys/$volume_uuid
    /data/misc_de/$user/vold/volume_keys/$volume_uuid
    /data/misc_ce/$user/vold/volume_keys/$volume_uuid

Currently fs_mkdirs() is used for this.  However, fs_mkdirs() doesn't
include the fsync()s of the parent directories that are needed to ensure
that the new directories are persisted to disk right away -- which is
important for encryption keys.

Add a utility function MkdirsSync() which does what is needed, and make
the appropriate places call it.

Test: Booted and checked log for "Created directory" message.
      Also ran 'atest vold_tests' to run the new unit test.
Change-Id: Ie9917b616433080139b8db3fd6877203ee6faf77
FsCrypt.cpp
MetadataCrypt.cpp
Utils.cpp
Utils.h
tests/Utils_test.cpp