summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_syscalls.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2008-02-23 01:01:49 +0000
committerdes <des@FreeBSD.org>2008-02-23 01:01:49 +0000
commitdf26e399aa077b14fb965be866012bccf2847bae (patch)
treef964310d3ee2e43cfebd6c2b2628bc7056a3aa02 /sys/kern/vfs_syscalls.c
parent78a1e4fcc29bdf9689366a67205160335e7897bd (diff)
downloadFreeBSD-src-df26e399aa077b14fb965be866012bccf2847bae.zip
FreeBSD-src-df26e399aa077b14fb965be866012bccf2847bae.tar.gz
This patch adds a new ktrace(2) record type, KTR_STRUCT, whose payload
consists of the null-terminated name and the contents of any structure you wish to record. A new ktrstruct() function constructs and emits a KTR_STRUCT record. It is accompanied by convenience macros for struct stat and struct sockaddr. In kdump(1), KTR_STRUCT records are handled by a dispatcher function that runs stringent sanity checks on its contents before handing it over to individual decoding funtions for each type of structure. Currently supported structures are struct stat and struct sockaddr for the AF_INET, AF_INET6 and AF_UNIX families; support for AF_APPLETALK and AF_IPX is present but disabled, as I am unable to test it properly. Since 's' was already taken, the letter 't' is used by ktrace(1) to enable KTR_STRUCT trace points, and in kdump(1) to enable their decoding. Derived from patches by Andrew Li <andrew2.li@citi.com>. PR: kern/117836 MFC after: 3 weeks
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r--sys/kern/vfs_syscalls.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index d05ca3a..8829a9c 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -38,6 +38,7 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
+#include "opt_ktrace.h"
#include "opt_mac.h"
#include <sys/param.h>
@@ -67,6 +68,9 @@ __FBSDID("$FreeBSD$");
#include <sys/jail.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
#include <machine/stdarg.h>
@@ -2120,6 +2124,10 @@ kern_stat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
if (error)
return (error);
*sbp = sb;
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_STRUCT))
+ ktrstat(&sb);
+#endif
return (0);
}
@@ -2171,6 +2179,10 @@ kern_lstat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp
if (error)
return (error);
*sbp = sb;
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_STRUCT))
+ ktrstat(&sb);
+#endif
return (0);
}
OpenPOWER on IntegriCloud