[PATCH] D42053: Add new NetBSD interceptors: devname(3), devname_r(3)
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 15 01:15:38 PST 2018
krytarowski created this revision.
krytarowski added reviewers: joerg, vitalybuka.
krytarowski added a project: Sanitizers.
Herald added a subscriber: kubamracek.
name=1
devname, devname_r - get device name
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
#include <sys/stat.h>
char *
devname(dev_t dev, mode_t type);
int
devname_r(dev_t dev, mode_t type, char *path, size_t len);
Sponsored by <The NetBSD Foundation>
Repository:
rL LLVM
https://reviews.llvm.org/D42053
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
lib/sanitizer_common/sanitizer_platform_interceptors.h
Index: lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -432,4 +432,7 @@
#define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION (!SI_WINDOWS && SI_NOT_FUCHSIA)
#define SANITIZER_INTERCEPT_BSD_SIGNAL SI_ANDROID
+#define SANITIZER_INTERCEPT_DEVNAME SI_NETBSD
+#define SANITIZER_INTERCEPT_DEVNAME_R SI_NETBSD
+
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -6463,6 +6463,35 @@
#define INIT_WCSCAT
#endif
+#if SANITIZER_INTERCEPT_DEVNAME
+INTERCEPTOR(char *, devname, u64 dev, u32 type) {
+ void *ctx;
+ char *name;
+ COMMON_INTERCEPTOR_ENTER(ctx, devname, dev, type);
+ name = REAL(devname)(dev, type);
+ if (name)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, REAL(strlen)(name) + 1);
+ return name;
+}
+#define INIT_DEVNAME COMMON_INTERCEPT_FUNCTION(devname);
+#else
+#define INIT_DEVNAME
+#endif
+
+#if SANITIZER_INTERCEPT_DEVNAME_R
+INTERCEPTOR(int, devname_r, u64 dev, u32 type, char *path, uptr len) {
+ void *ctx;
+ int res;
+ COMMON_INTERCEPTOR_ENTER(ctx, devname_r, dev, type, path, len);
+ res = REAL(devname_r)(dev, type, path, len);
+ if (!res)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, path, REAL(strlen)(path) + 1);
+ return res;
+}
+#define INIT_DEVNAME_R COMMON_INTERCEPT_FUNCTION(devname_r);
+#else
+#define INIT_DEVNAME_R
+
static void InitializeCommonInterceptors() {
static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
@@ -6674,6 +6703,8 @@
INIT_GETLOADAVG;
INIT_WCSLEN;
INIT_WCSCAT;
+ INIT_DEVNAME;
+ INIT_DEVNAME_R;
#if SANITIZER_NETBSD
COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42053.129810.patch
Type: text/x-patch
Size: 2083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180115/5dba48d6/attachment.bin>
More information about the llvm-commits
mailing list