FreeBSD Bugzilla – Attachment 219580 Details for
Bug 251061
Add filemon(1)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add filemon(1)
filemon-util.diff (text/plain), 5.90 KB, created by
Daniel O'Connor
on 2020-11-12 02:31:51 UTC
(
hide
)
Description:
Add filemon(1)
Filename:
MIME Type:
Creator:
Daniel O'Connor
Created:
2020-11-12 02:31:51 UTC
Size:
5.90 KB
patch
obsolete
>diff --git a/share/man/man4/filemon.4 b/share/man/man4/filemon.4 >index 24707fe3e..c4b2a63ff 100644 >--- a/share/man/man4/filemon.4 >+++ b/share/man/man4/filemon.4 >@@ -226,6 +226,7 @@ device to write the > buffer contents to it. > .Sh SEE ALSO > .Xr dtrace 1 , >+.Xr filemon 1 , > .Xr ktrace 1 , > .Xr script 1 , > .Xr truss 1 , >diff --git a/usr.bin/Makefile b/usr.bin/Makefile >index 8ea3b1c2b..d9ff679c5 100644 >--- a/usr.bin/Makefile >+++ b/usr.bin/Makefile >@@ -40,6 +40,7 @@ SUBDIR= alias \ > expand \ > false \ > fetch \ >+ filemon \ > find \ > fmt \ > fold \ >diff --git a/usr.bin/filemon/Makefile b/usr.bin/filemon/Makefile >new file mode 100644 >index 000000000..028546efb >--- /dev/null >+++ b/usr.bin/filemon/Makefile >@@ -0,0 +1,6 @@ >+# $FreeBSD$ >+ >+PROG= filemon >+SRCS= filemon.c >+ >+.include <bsd.prog.mk> >diff --git a/usr.bin/filemon/filemon.1 b/usr.bin/filemon/filemon.1 >new file mode 100644 >index 000000000..03973378c >--- /dev/null >+++ b/usr.bin/filemon/filemon.1 >@@ -0,0 +1,60 @@ >+.\" Copyright (c) 2002 >+.\" Daniel O'Connor <darius@dons.net.au> >+.\" >+.\" Redistribution and use in source and binary forms, with or without >+.\" modification, are permitted provided that the following conditions >+.\" are met: >+.\" 1. Redistributions of source code must retain the above copyright >+.\" notice, this list of conditions and the following disclaimer. >+.\" 2. Redistributions in binary form must reproduce the above copyright >+.\" notice, this list of conditions and the following disclaimer in the >+.\" documentation and/or other materials provided with the distribution. >+.\" >+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE >+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT >+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+.\" SUCH DAMAGE. >+.\" >+.\" $FreeBSD$ >+.\" >+.Dd November 12, 2020 >+.Dt FILEMON 1 >+.Os >+.Sh NAME >+.Nm filemon >+.Nd log child process file access using filemon >+.Sh SYNOPSIS >+.Nm >+.Op Fl f Ar trfile >+.Ar command >+.Sh DESCRIPTION >+The >+.Nm >+utility is a simple wrapper around the >+.Xr filemon 4 >+kernel facility (see that manual page for the file format). >+Unlike >+.Xr ktrace 1 >+the trace file can be a named pipe. >+The options are: >+.Bl -tag -width indent >+.It Fl f Ar trfile >+Log trace records to >+.Ar trfile >+instead of >+.Pa filemon.out . >+.Sh SEE ALSO >+.Xr ktrace 1 , >+.Xr filemon 4 >+.Sh AUTHORS >+The >+.Nm >+utility was written by >+.An Daniel O'Connor. >diff --git a/usr.bin/filemon/filemon.c b/usr.bin/filemon/filemon.c >new file mode 100644 >index 000000000..ed2cc0e65 >--- /dev/null >+++ b/usr.bin/filemon/filemon.c >@@ -0,0 +1,91 @@ >+/*- >+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD >+ * >+ * Copyright (c) 2020 Daniel O'Connor <darius@dons.net.au> >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in this position and unchanged. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE >+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT >+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+ * SUCH DAMAGE. >+ * >+ * $FreeBSD$ >+ */ >+ >+#include <stdio.h> >+#include <stdlib.h> >+#include <sys/types.h> >+#include <sys/stat.h> >+#include <sys/wait.h> >+#include <sys/ioctl.h> >+#include <dev/filemon/filemon.h> >+#include <fcntl.h> >+#include <err.h> >+#include <unistd.h> >+ >+static void >+usage(void) >+{ >+ fputs(" filemon [-f trfile] command [...]\n", stderr); >+ exit(1); >+} >+ >+int main(int argc, char **argv) { >+ char ch; >+ int fm_fd, fm_log; >+ pid_t child; >+ const char *tracefile = "filemon.out"; >+ >+ while ((ch = getopt(argc,argv,"f:")) != -1) >+ switch((char)ch) { >+ case 'f': >+ tracefile = optarg; >+ break; >+ default: >+ usage(); >+ } >+ >+ argv += optind; >+ argc -= optind; >+ >+ /* Need something to run */ >+ if (argc == 0) >+ usage(); >+ >+ if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1) >+ err(1, "open(\"/dev/filemon\", O_RDWR)"); >+ if ((fm_log = open(tracefile, >+ O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, DEFFILEMODE)) == -1) >+ err(1, "Cannot open trace file %s", tracefile); >+ >+ if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1) >+ err(1, "Cannot set filemon log file descriptor"); >+ >+ if ((child = fork()) == 0) { >+ child = getpid(); >+ if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) >+ err(1, "Cannot set filemon PID"); >+ execvp(*argv, argv); >+ err(1, "exec of '%s' failed", *argv); >+ } else { >+ wait(&child); >+ close(fm_fd); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251061
: 219580