|
NAMEfilemon —
the filemon device
SYNOPSIS#include <dev/filemon/filemon.h>
DESCRIPTIONThefilemon device allows a process to collect file
operations data of its children. The device
/dev/filemon responds to two
ioctl(2)
calls.
System calls are denoted using the following single letters:
Note that ‘ IOCTLSUser mode programs communicate with thefilemon driver
through a number of ioctls which are described below. Each takes a single
argument.
RETURN VALUESTheioctl () function returns the value 0 if successful;
otherwise the value -1 is returned and the global variable
errno is set to indicate the error.
ERRORSTheioctl () system call with
FILEMON_SET_FD will fail if:
The
The
FILES
EXAMPLES#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 open_filemon(void) { pid_t child; int fm_fd, fm_log; if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1) err(1, "open(\"/dev/filemon\", O_RDWR)"); if ((fm_log = open("filemon.out", O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, DEFFILEMODE)) == -1) err(1, "open(filemon.out)"); 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"); /* Do something here. */ } else { wait(&child); close(fm_fd); } } Creates a file named filemon.out and
configures the SEE ALSOdtrace(1), ktrace(1), script(1), truss(1), ioctl(2)HISTORYAfilemon device appeared in FreeBSD
9.1.
BUGSUnloading the module may panic the system, thus requires usingkldunload -f .
Visit the GSP FreeBSD Man Page Interface. |