From 51e820d0d8bbd5586cb8c627e243d75b45fdf32f Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 6 Dec 2018 17:04:18 +0000 Subject: [PATCH] [Sanitizer] getmntinfo support in FreeBSD Reviewers: krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D55354 llvm-svn: 348500 --- .../lib/sanitizer_common/sanitizer_common_interceptors.inc | 4 ++++ .../lib/sanitizer_common/sanitizer_platform_interceptors.h | 2 +- .../sanitizer_common/TestCases/{NetBSD => Posix}/getmntinfo.cc | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) rename compiler-rt/test/sanitizer_common/TestCases/{NetBSD => Posix}/getmntinfo.cc (73%) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 699ec5d..2ec888c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -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; } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h index b29a37b..80d5e2c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -518,7 +518,7 @@ #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 diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/getmntinfo.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc similarity index 73% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/getmntinfo.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc index d27e995..e6afa4a 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/getmntinfo.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cc @@ -1,8 +1,14 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s +// +// UNSUPPORTED: linux, darwin, solaris #include +#if defined(__NetBSD__) #include +#else +#include +#endif #include #include @@ -11,7 +17,11 @@ 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"); -- 2.7.4