svn commit: r236647 - in projects/bmake: share/man/man4
sys/dev/filemon sys/modules sys/modules/filemon
tools/regression/filemon
David E. O'Brien
obrien at FreeBSD.org
Wed Jun 6 00:20:14 UTC 2012
Author: obrien
Date: Wed Jun 6 00:20:13 2012
New Revision: 236647
URL: http://svn.freebsd.org/changeset/base/236647
Log:
MFC: r236422, r236592, r236593, r236594, r236620, r236621, r236622, & r236637
filemon(4)
Added:
projects/bmake/share/man/man4/filemon.4
- copied, changed from r236593, head/share/man/man4/filemon.4
projects/bmake/sys/dev/filemon/
- copied from r236592, head/sys/dev/filemon/
projects/bmake/sys/modules/filemon/
- copied from r236592, head/sys/modules/filemon/
projects/bmake/tools/regression/filemon/
- copied from r236594, head/tools/regression/filemon/
Modified:
projects/bmake/share/man/man4/Makefile
projects/bmake/sys/modules/Makefile
projects/bmake/tools/regression/filemon/filemontest.c
Directory Properties:
projects/bmake/ (props changed)
projects/bmake/share/man/man4/ (props changed)
projects/bmake/sys/ (props changed)
Modified: projects/bmake/share/man/man4/Makefile
==============================================================================
--- projects/bmake/share/man/man4/Makefile Tue Jun 5 23:48:20 2012 (r236646)
+++ projects/bmake/share/man/man4/Makefile Wed Jun 6 00:20:13 2012 (r236647)
@@ -126,6 +126,7 @@ MAN= aac.4 \
fdt.4 \
fdtbus.4 \
ffclock.4 \
+ filemon.4 \
firewire.4 \
fpa.4 \
fwe.4 \
Copied and modified: projects/bmake/share/man/man4/filemon.4 (from r236593, head/share/man/man4/filemon.4)
==============================================================================
--- head/share/man/man4/filemon.4 Mon Jun 4 22:59:06 2012 (r236593, copy source)
+++ projects/bmake/share/man/man4/filemon.4 Wed Jun 6 00:20:13 2012 (r236647)
@@ -50,63 +50,74 @@ responds to two
calls.
.Pp
System calls are denoted using the following single letters:
+.Pp
.Bl -tag -width indent -compact
-.It Dq Li C
+.It Ql C
.Xr chdir 2
-.It Dq Li D
+.It Ql D
.Xr unlink 2
-.It Dq Li E
+.It Ql E
.Xr exec 2
-.It Dq Li F
+.It Ql F
.Xr fork 2 ,
.Xr vfork 2
-.It Dq Li L
+.It Ql L
.Xr link 2 ,
.Xr linkat 2 ,
.Xr symlink 2 ,
.Xr symlinkat 2
-.It Dq Li M
+.It Ql M
.Xr rename 2
-.It Dq Li R
+.It Ql R
.Xr open 2
for read
-.It Dq Li S
+.It Ql S
.Xr stat 2
-.It Dq Li W
+.It Ql W
.Xr open 2
for write
-.It Dq Li X
+.It Ql X
.Xr _exit 2
.El
.Pp
Note that
-.Dq R
+.Ql R
following
-.Dq W
+.Ql W
records can represent a single
.Xr open 2
for R/W,
or two seperate
.Xr open 2
calls, one for
-R
+.Ql R
and one for
-W.
+.Ql W .
.Sh IOCTLS
-User mode programs communicate with the filemon driver through a
-number of ioctls which are described below.
+User mode programs communicate with the
+.Nm
+driver through a number of ioctls which are described below.
Each takes a single argument.
-.Bl -tag -width FILEMON_SET_PID
+.Bl -tag -width ".Dv FILEMON_SET_PID"
.It Dv FILEMON_SET_FD
Write the internal tracing buffer to the supplied open file descriptor.
-.It Dv FILEMON_SET_PID .
+.It Dv FILEMON_SET_PID
Child process ID to trace.
.El
-.Pp
.Sh RETURN VALUES
-The ioctl returns zero on success and non-zero on failure.
+.\" .Rv -std ioctl
+The
+.Fn ioctl
+function returns the value 0 if successful;
+otherwise the value \-1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh FILES
+.Bl -tag -width ".Pa /dev/filemon"
+.It Pa /dev/filemon
+.El
.Sh EXAMPLES
-.Bd -literal -offset indent
+.Bd -literal
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -122,23 +133,24 @@ open_filemon(void)
int fm_fd, fm_log;
if ((fm_fd = open("/dev/filemon", O_RDWR)) == -1)
- err(1, "open(\"/dev/filemon\", O_RDWR)");
+ err(1, "open(\e"/dev/filemon\e", O_RDWR)");
if ((fm_log = open("filemon.out",
O_CREAT | O_WRONLY | O_TRUNC, DEFFILEMODE)) == -1)
err(1, "open(filemon.out)");
- if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0)
+ if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1)
err(1, "Cannot set filemon log file descriptor");
/* Set up these two fd's to close on exec. */
(void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC);
(void)fcntl(fm_log, F_SETFD, FD_CLOEXEC);
if ((child = fork()) == 0) {
+ child = getpid();
+ if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1)
+ err(1, "Cannot set filemon PID");
/* Do something here. */
return 0;
} else {
- if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0)
- err(1, "Cannot set filemon PID");
wait(&child);
close(fm_fd);
}
@@ -150,11 +162,9 @@ Creates a file named
.Pa filemon.out
and configures the
.Nm
-device to write the filemon buffer contents to it.
-.Sh FILES
-.Bl -tag -width /dev/zero
-.It Pa /dev/filemon
-.El
+device to write the
+.Nm
+buffer contents to it.
.Sh SEE ALSO
.Xr dtrace 1 ,
.Xr ktrace 1 ,
Modified: projects/bmake/sys/modules/Makefile
==============================================================================
--- projects/bmake/sys/modules/Makefile Tue Jun 5 23:48:20 2012 (r236646)
+++ projects/bmake/sys/modules/Makefile Wed Jun 6 00:20:13 2012 (r236647)
@@ -5,7 +5,8 @@
# Modules that include binary-only blobs of microcode should be selectable by
# MK_SOURCELESS_UCODE option (see below).
-SUBDIR= ${_3dfx} \
+SUBDIR= \
+ ${_3dfx} \
${_3dfx_linux} \
${_aac} \
accf_data \
@@ -105,6 +106,7 @@ SUBDIR= ${_3dfx} \
fdc \
fdescfs \
${_fe} \
+ ${_filemon} \
firewire \
firmware \
${_fxp} \
@@ -356,6 +358,10 @@ SUBDIR= ${_3dfx} \
${_zfs} \
zlib \
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+_filemon= filemon
+.endif
+
.if ${MACHINE_CPUARCH} != "powerpc" && ${MACHINE_CPUARCH} != "arm" && \
${MACHINE_CPUARCH} != "mips"
_syscons= syscons
Modified: projects/bmake/tools/regression/filemon/filemontest.c
==============================================================================
--- head/tools/regression/filemon/filemontest.c Mon Jun 4 22:59:33 2012 (r236594)
+++ projects/bmake/tools/regression/filemon/filemontest.c Wed Jun 6 00:20:13 2012 (r236647)
@@ -54,22 +54,27 @@ main(void) {
if ((fm_log = mkstemp(log_name)) == -1)
err(1, "mkstemp(%s)", log_name);
- if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0)
+ if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1)
err(1, "Cannot set filemon log file descriptor");
/* Set up these two fd's to close on exec. */
(void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC);
(void)fcntl(fm_log, F_SETFD, FD_CLOEXEC);
- if ((child = fork()) == 0) {
+ switch (child = fork()) {
+ case 0:
+ child = getpid();
+ if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1)
+ err(1, "Cannot set filemon PID to %d", child);
system("./test_script.sh");
- return 0;
- } else {
- if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0)
- err(1, "Cannot set filemon PID");
+ break;
+ case -1:
+ err(1, "Cannot fork");
+ default:
wait(&child);
close(fm_fd);
// printf("Results in %s\n", log_name);
+ break;
}
return 0;
}
More information about the svn-src-projects
mailing list