From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 15:57:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C3F941065710; Fri, 29 Jun 2012 15:57:25 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A89028FC18; Fri, 29 Jun 2012 15:57:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5TFvP91055063; Fri, 29 Jun 2012 15:57:25 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5TFvPLb055057; Fri, 29 Jun 2012 15:57:25 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206291557.q5TFvPLb055057@svn.freebsd.org> From: "David E. O'Brien" Date: Fri, 29 Jun 2012 15:57:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237795 - in stable/9: share/man/man4 sys/dev/filemon sys/modules sys/modules/filemon tools/regression/filemon X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 15:57:26 -0000 Author: obrien Date: Fri Jun 29 15:57:25 2012 New Revision: 237795 URL: http://svn.freebsd.org/changeset/base/237795 Log: MFC: r236592 r236593 r236594 r236620 r236621 r236622 r236637 r237794: filemon(4) Added: stable/9/share/man/man4/filemon.4 - copied, changed from r236593, head/share/man/man4/filemon.4 stable/9/sys/dev/filemon/ - copied from r236592, head/sys/dev/filemon/ stable/9/sys/modules/filemon/ - copied from r236592, head/sys/modules/filemon/ stable/9/tools/regression/filemon/ - copied from r236594, head/tools/regression/filemon/ Modified: stable/9/share/man/man4/Makefile stable/9/sys/modules/Makefile stable/9/tools/regression/filemon/Makefile stable/9/tools/regression/filemon/filemontest.c Directory Properties: stable/9/ (props changed) stable/9/share/ (props changed) stable/9/share/man/ (props changed) stable/9/share/man/man4/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/modules/ (props changed) stable/9/tools/ (props changed) Modified: stable/9/share/man/man4/Makefile ============================================================================== --- stable/9/share/man/man4/Makefile Fri Jun 29 15:54:07 2012 (r237794) +++ stable/9/share/man/man4/Makefile Fri Jun 29 15:57:25 2012 (r237795) @@ -126,6 +126,7 @@ MAN= aac.4 \ fdc.4 \ fdt.4 \ fdtbus.4 \ + filemon.4 \ firewire.4 \ fpa.4 \ fwe.4 \ Copied and modified: stable/9/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) +++ stable/9/share/man/man4/filemon.4 Fri Jun 29 15:57:25 2012 (r237795) @@ -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 #include #include @@ -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: stable/9/sys/modules/Makefile ============================================================================== --- stable/9/sys/modules/Makefile Fri Jun 29 15:54:07 2012 (r237794) +++ stable/9/sys/modules/Makefile Fri Jun 29 15:57:25 2012 (r237795) @@ -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 \ @@ -102,6 +103,7 @@ SUBDIR= ${_3dfx} \ fdc \ fdescfs \ ${_fe} \ + ${_filemon} \ firewire \ firmware \ ${_fxp} \ @@ -352,6 +354,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: stable/9/tools/regression/filemon/Makefile ============================================================================== --- head/tools/regression/filemon/Makefile Mon Jun 4 22:59:33 2012 (r236594) +++ stable/9/tools/regression/filemon/Makefile Fri Jun 29 15:57:25 2012 (r237795) @@ -9,16 +9,18 @@ CFLAGS+= -I${.CURDIR}/../../../sys # Cannot use .OBJDIR -- 'filemontest' expects 'test_script.sh' in . test: ${PROG} clean-test +.for BIN in ${PROG} ${PROG}32 cd ${.CURDIR} ; \ for A in 1 2 3 4 5 6 7 8 9 0; do \ for B in 1 2 3 4 5 6 7 8 9 0; do \ for C in 1 2 3 4 5 6 7 8 9 0; do \ - ${.OBJDIR}/${PROG} ;\ + test -x ${BIN} && ${.OBJDIR}/${BIN} ;\ done ;\ done ;\ done @cd ${.CURDIR} ; set +e ; egrep '(Start|Stop) .*\.' filemon_log.* | \ grep -q -v '\.[0-9][0-9][0-9][0-9][0-9][0-9]$$' || echo "Time stamp format OK" +.endfor clean-test: cd ${.CURDIR} ; rm -f filemon_log.* Modified: stable/9/tools/regression/filemon/filemontest.c ============================================================================== --- head/tools/regression/filemon/filemontest.c Mon Jun 4 22:59:33 2012 (r236594) +++ stable/9/tools/regression/filemon/filemontest.c Fri Jun 29 15:57:25 2012 (r237795) @@ -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; }