[PATCH] D65245: [profile] In Android, do not mkdir() dirs in GCOV_PREFIX
Pirama Arumuga Nainar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 25 15:13:29 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367064: [profile] In Android, do not mkdir() dirs in GCOV_PREFIX (authored by pirama, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D65245?vs=211833&id=211834#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65245/new/
https://reviews.llvm.org/D65245
Files:
compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
Index: compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
===================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
@@ -39,8 +39,25 @@
COMPILER_RT_VISIBILITY
void __llvm_profile_recursive_mkdir(char *path) {
int i;
+ int start = 1;
- for (i = 1; path[i] != '\0'; ++i) {
+#if defined(__ANDROID__) && defined(__ANDROID_API__) && \
+ defined(__ANDROID_API_FUTURE__) && \
+ __ANDROID_API__ == __ANDROID_API_FUTURE__
+ // Avoid spammy selinux denial messages in Android by not attempting to
+ // create directories in GCOV_PREFIX. These denials occur when creating (or
+ // even attempting to stat()) top-level directories like "/data".
+ //
+ // Do so by ignoring ${GCOV_PREFIX} when invoking mkdir().
+ const char *gcov_prefix = getenv("GCOV_PREFIX");
+ if (gcov_prefix != NULL) {
+ const int gcov_prefix_len = strlen(gcov_prefix);
+ if (strncmp(path, gcov_prefix, gcov_prefix_len) == 0)
+ start = gcov_prefix_len;
+ }
+#endif
+
+ for (i = start; path[i] != '\0'; ++i) {
char save = path[i];
if (!IS_DIR_SEPARATOR(path[i]))
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65245.211834.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190725/155ffa41/attachment.bin>
More information about the llvm-commits
mailing list