summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-15 23:09:28 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-15 23:09:28 +0000
commitc2bb5e58b24b1918982ebeda361d49452ad0a0bf (patch)
tree90de8044e76b3eae64feb7059eee0b2dbe864b69
parent5b1856e22ae0dc015c708bfc07859113deb02fb3 (diff)
parentf71981ace4eab2f970e22d9511f7c69cbd41406f (diff)
downloadincremental_delivery-android11-qpr1-d-s1-release.tar.gz
Change-Id: Ic9d118b1240348f4cdf0a3a2dce28c97443ee59b
-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;
}