Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

filemon(4) [freebsd man page]

FILEMON(4)						   BSD Kernel Interfaces Manual 						FILEMON(4)

filemon -- the filemon device SYNOPSIS
#include <dev/filemon/filemon.h> DESCRIPTION
The filemon 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: 'C' chdir(2) 'D' unlink(2) 'E' exec(2) 'F' fork(2), vfork(2) 'L' link(2), linkat(2), symlink(2), symlinkat(2) 'M' rename(2) 'R' open(2) for read 'S' stat(2) 'W' open(2) for write 'X' _exit(2) Note that 'R' following 'W' records can represent a single open(2) for R/W, or two separate open(2) calls, one for 'R' and one for 'W'. Note that only successful system calls are captured. IOCTLS
User mode programs communicate with the filemon driver through a number of ioctls which are described below. Each takes a single argument. FILEMON_SET_FD Write the internal tracing buffer to the supplied open file descriptor. FILEMON_SET_PID Child process ID to trace. RETURN VALUES
The ioctl() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. FILES
/dev/filemon 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 filemon device to write the filemon buffer contents to it. SEE ALSO
dtrace(1), ktrace(1), script(1), truss(1), ioctl(2) HISTORY
A filemon device appeared in FreeBSD 9.1. BSD
June 14, 2013 BSD

Check Out this Related Man Page

SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

script -- make typescript of terminal session SYNOPSIS
script [-adfkpqr] [-F pipe] [-t time] [file [command ...]] DESCRIPTION
The script utility makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. If the argument command is given, script will run the specified command with an optional argument vector instead of an interactive shell. The following options are available: -a Append the output to file or typescript, retaining the prior contents. -d When playing back a session with the -p flag, do not sleep between records when playing back a timestamped session. -F pipe Immediately flush output after each write. This will allow a user to create a named pipe using mkfifo(1) and another user may watch the live session using a utility like cat(1). -f Create file.filemon or typescript.filemon using filemon(4). -k Log keys sent to the program as well as output. -p Play back a session recorded with the -r flag in real time. -q Run in quiet mode, omit the start, stop and command status messages. -r Record a session with input, output, and timestamping. -t time Specify the interval at which the script output file will be flushed to disk, in seconds. A value of 0 causes script to flush after every character I/O event. The default interval is 30 seconds. The script ends when the forked shell (or command) exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-D (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. The script utility works best with commands that do not manipulate the screen. The results are meant to emulate a hardcopy terminal, not an addressable one. ENVIRONMENT
The following environment variables are utilized by script: SCRIPT The SCRIPT environment variable is added to the sub-shell. If SCRIPT already existed in the users environment, its value is overwrit- ten within the sub-shell. The value of SCRIPT is the name of the typescript file. SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1), filemon(4) (for the history mechanism). HISTORY
The script command appeared in 3.0BSD. The -d, -p and -r options first appeared in NetBSD 2.0 and were ported to FreeBSD 9.2. BUGS
The script utility places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. It is not possible to specify a command without also naming the script file because of argument parsing compatibility issues. When running in -k mode, echo cancelling is far from ideal. The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when the terminal is in a raw mode where the program being run is doing manual echo. If script reads zero bytes from the terminal, it switches to a mode when it only attempts to read once a second until there is data to read. This prevents script from spinning on zero-byte reads, but might cause a 1-second delay in processing of user input. BSD
December 4, 2013 BSD
Man Page

Featured Tech Videos