summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-16 18:45:28 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-16 18:45:28 +0000
commit2d81becff4f528fa73ee1727083a812f23b56aaa (patch)
tree90de8044e76b3eae64feb7059eee0b2dbe864b69
parent6dc327ee7bd694ca669ebe6d00b049fa2f7cb3e2 (diff)
parent6c1d6414fd3b155cd2be344693f61f414bff20ea (diff)
downloadincremental_delivery-android11-mainline-sparse-2021-jan-release.tar.gz
Change-Id: I6090df0708e5bfd0eedb60ada99217efb7cd26e2
-rw-r--r--incfs/incfs.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/incfs/incfs.cpp b/incfs/incfs.cpp
index c98acb2..7994c54 100644
--- a/incfs/incfs.cpp
+++ b/incfs/incfs.cpp
@@ -403,6 +403,22 @@ IncFsFileId IncFs_FileIdFromMetadata(IncFsSpan metadata) {
return id;
}
+static bool restoreconControlFiles(std::string_view targetDir) {
+ const std::string controlFilePaths[] = {path::join(targetDir, INCFS_PENDING_READS_FILENAME),
+ path::join(targetDir, INCFS_LOG_FILENAME)};
+ for (size_t i = 0; i < std::size(controlFilePaths); i++) {
+ if (const auto err = selinux_android_restorecon(controlFilePaths[i].c_str(),
+ SELINUX_ANDROID_RESTORECON_FORCE);
+ err != 0) {
+ PLOG(ERROR) << "[incfs] Failed to restorecon: " << controlFilePaths[i]
+ << " error code: " << err;
+ errno = -err;
+ return false;
+ }
+ }
+ return true;
+}
+
IncFsControl* IncFs_Mount(const char* backingPath, const char* targetDir,
IncFsMountOptions options) {
if (!init().enabledAndReady()) {
@@ -440,10 +456,7 @@ IncFsControl* IncFs_Mount(const char* backingPath, const char* targetDir,
return nullptr;
}
- if (const auto err = selinux_android_restorecon(targetDir, SELINUX_ANDROID_RESTORECON_RECURSE);
- err != 0) {
- PLOG(ERROR) << "[incfs] Failed to restorecon: " << err;
- errno = -err;
+ if (!restoreconControlFiles(targetDir)) {
return nullptr;
}