[Sanitizer] getmntinfo support in FreeBSD
authorDavid Carlier <devnexen@gmail.com>
Thu, 6 Dec 2018 17:04:18 +0000 (17:04 +0000)
committerDavid Carlier <devnexen@gmail.com>
Thu, 6 Dec 2018 17:04:18 +0000 (17:04 +0000)
Reviewers: krytarowski

Reviewed By: krytarowski

Differential Revision: https://reviews.llvm.org/D55354

llvm-svn: 348500

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc [moved from compiler-rt/test/sanitizer_common/TestCases/NetBSD/getmntinfo.cc with 73% similarity]

index 699ec5d..2ec888c 100644 (file)
@@ -7278,7 +7278,11 @@ INTERCEPTOR(int, getmntinfo, void **mntbufp, int flags) {
   if (cnt > 0 && mntbufp) {
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, mntbufp, sizeof(void *));
     if (*mntbufp)
+#if SANITIZER_NETBSD
       COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *mntbufp, cnt * struct_statvfs_sz);
+#else
+      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *mntbufp, cnt * struct_statfs_sz);
+#endif
   }
   return cnt;
 }
index b29a37b..80d5e2c 100644 (file)
 #define SANITIZER_INTERCEPT_NETENT SI_NETBSD
 #define SANITIZER_INTERCEPT_SETVBUF (SI_NETBSD || SI_FREEBSD || \
   SI_LINUX || SI_MAC)
-#define SANITIZER_INTERCEPT_GETMNTINFO SI_NETBSD
+#define SANITIZER_INTERCEPT_GETMNTINFO (SI_NETBSD || SI_FREEBSD)
 #define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD
 #define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
 #define SANITIZER_INTERCEPT_REGEX SI_NETBSD
@@ -1,8 +1,14 @@
 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
+//
+// UNSUPPORTED: linux, darwin, solaris
 
 #include <sys/types.h>
 
+#if defined(__NetBSD__)
 #include <sys/statvfs.h>
+#else
+#include <sys/mount.h>
+#endif
 
 #include <err.h>
 #include <stdio.h>
 int main(void) {
   printf("getmntinfo\n");
 
+#if defined(__NetBSD__)
   struct statvfs *fss;
+#else
+  struct statfs *fss;
+#endif
   int nfss = getmntinfo(&fss, MNT_NOWAIT);
   if (nfss <= 0)
     errx(1, "getmntinfo");