Merge 0b26ecbff499e9140177912281eab785e523a0de on remote branch
Change-Id: I63907d383f2ae4a4a50fa252b782cc9d759d0d87
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 @@
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 @@
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;
}