MFC r300892,r300893,r301130,r301404,r301414,r301460:
r300892: Rename function to be less generic. r300893: Don't truncate existing error when writing the log. r301130: Enable filemon on all architectures. r301404: Support all architectures by just using sysent. r301414: Fix build after r301404. r301460: Cleanup COMPAT_FREEBSD32 support.
This commit is contained in:
parent
37956f7289
commit
fa265a81a9
@ -54,16 +54,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "filemon.h"
|
||||
|
||||
#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
|
||||
#if defined(COMPAT_FREEBSD32)
|
||||
#include <compat/freebsd32/freebsd32_syscall.h>
|
||||
#include <compat/freebsd32/freebsd32_proto.h>
|
||||
|
||||
extern struct sysentvec ia32_freebsd_sysvec;
|
||||
#include <compat/freebsd32/freebsd32_util.h>
|
||||
#endif
|
||||
|
||||
extern struct sysentvec elf32_freebsd_sysvec;
|
||||
extern struct sysentvec elf64_freebsd_sysvec;
|
||||
|
||||
static d_close_t filemon_close;
|
||||
static d_ioctl_t filemon_ioctl;
|
||||
static d_open_t filemon_open;
|
||||
@ -188,7 +184,7 @@ filemon_drop(struct filemon *filemon)
|
||||
#include "filemon_wrapper.c"
|
||||
|
||||
static void
|
||||
filemon_comment(struct filemon *filemon)
|
||||
filemon_write_header(struct filemon *filemon)
|
||||
{
|
||||
int len;
|
||||
struct timeval now;
|
||||
@ -377,7 +373,7 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused,
|
||||
&filemon->fp);
|
||||
if (error == 0)
|
||||
/* Write the file header. */
|
||||
filemon_comment(filemon);
|
||||
filemon_write_header(filemon);
|
||||
break;
|
||||
|
||||
/* Set the monitored process ID. */
|
||||
|
@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/imgact.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include "opt_compat.h"
|
||||
@ -65,7 +66,7 @@ filemon_output(struct filemon *filemon, char *msg, size_t len)
|
||||
bwillwrite();
|
||||
|
||||
error = fo_write(filemon->fp, &auio, curthread->td_ucred, 0, curthread);
|
||||
if (error != 0)
|
||||
if (error != 0 && filemon->error == 0)
|
||||
filemon->error = error;
|
||||
}
|
||||
|
||||
@ -402,33 +403,26 @@ filemon_event_process_fork(void *arg __unused, struct proc *p1,
|
||||
static void
|
||||
filemon_wrapper_install(void)
|
||||
{
|
||||
#if defined(__LP64__)
|
||||
struct sysent *sv_table = elf64_freebsd_sysvec.sv_table;
|
||||
#else
|
||||
struct sysent *sv_table = elf32_freebsd_sysvec.sv_table;
|
||||
#endif
|
||||
|
||||
sv_table[SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
|
||||
sv_table[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
|
||||
sv_table[SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
|
||||
sv_table[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
|
||||
sv_table[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
|
||||
sv_table[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
|
||||
sv_table[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
|
||||
sv_table[SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
|
||||
sysent[SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
|
||||
sysent[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
|
||||
sysent[SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
|
||||
sysent[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
|
||||
sysent[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
|
||||
sysent[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
|
||||
sysent[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
|
||||
sysent[SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
|
||||
|
||||
#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
|
||||
sv_table = ia32_freebsd_sysvec.sv_table;
|
||||
|
||||
sv_table[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
|
||||
sv_table[FREEBSD32_SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
|
||||
sv_table[FREEBSD32_SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
|
||||
sv_table[FREEBSD32_SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
|
||||
sv_table[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
|
||||
sv_table[FREEBSD32_SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
|
||||
sv_table[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
|
||||
sv_table[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
|
||||
#endif /* COMPAT_ARCH32 */
|
||||
#if defined(COMPAT_FREEBSD32)
|
||||
freebsd32_sysent[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
|
||||
freebsd32_sysent[FREEBSD32_SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
|
||||
freebsd32_sysent[FREEBSD32_SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
|
||||
freebsd32_sysent[FREEBSD32_SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
|
||||
freebsd32_sysent[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
|
||||
freebsd32_sysent[FREEBSD32_SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
|
||||
freebsd32_sysent[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
|
||||
freebsd32_sysent[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
|
||||
#endif /* COMPAT_FREEBSD32 */
|
||||
|
||||
filemon_exec_tag = EVENTHANDLER_REGISTER(process_exec,
|
||||
filemon_event_process_exec, NULL, EVENTHANDLER_PRI_LAST);
|
||||
@ -441,33 +435,26 @@ filemon_wrapper_install(void)
|
||||
static void
|
||||
filemon_wrapper_deinstall(void)
|
||||
{
|
||||
#if defined(__LP64__)
|
||||
struct sysent *sv_table = elf64_freebsd_sysvec.sv_table;
|
||||
#else
|
||||
struct sysent *sv_table = elf32_freebsd_sysvec.sv_table;
|
||||
#endif
|
||||
|
||||
sv_table[SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
|
||||
sv_table[SYS_open].sy_call = (sy_call_t *)sys_open;
|
||||
sv_table[SYS_openat].sy_call = (sy_call_t *)sys_openat;
|
||||
sv_table[SYS_rename].sy_call = (sy_call_t *)sys_rename;
|
||||
sv_table[SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
|
||||
sv_table[SYS_link].sy_call = (sy_call_t *)sys_link;
|
||||
sv_table[SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
|
||||
sv_table[SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
|
||||
sysent[SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
|
||||
sysent[SYS_open].sy_call = (sy_call_t *)sys_open;
|
||||
sysent[SYS_openat].sy_call = (sy_call_t *)sys_openat;
|
||||
sysent[SYS_rename].sy_call = (sy_call_t *)sys_rename;
|
||||
sysent[SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
|
||||
sysent[SYS_link].sy_call = (sy_call_t *)sys_link;
|
||||
sysent[SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
|
||||
sysent[SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
|
||||
|
||||
#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
|
||||
sv_table = ia32_freebsd_sysvec.sv_table;
|
||||
|
||||
sv_table[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
|
||||
sv_table[FREEBSD32_SYS_open].sy_call = (sy_call_t *)sys_open;
|
||||
sv_table[FREEBSD32_SYS_openat].sy_call = (sy_call_t *)sys_openat;
|
||||
sv_table[FREEBSD32_SYS_rename].sy_call = (sy_call_t *)sys_rename;
|
||||
sv_table[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
|
||||
sv_table[FREEBSD32_SYS_link].sy_call = (sy_call_t *)sys_link;
|
||||
sv_table[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
|
||||
sv_table[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
|
||||
#endif /* COMPAT_ARCH32 */
|
||||
#if defined(COMPAT_FREEBSD32)
|
||||
freebsd32_sysent[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
|
||||
freebsd32_sysent[FREEBSD32_SYS_open].sy_call = (sy_call_t *)sys_open;
|
||||
freebsd32_sysent[FREEBSD32_SYS_openat].sy_call = (sy_call_t *)sys_openat;
|
||||
freebsd32_sysent[FREEBSD32_SYS_rename].sy_call = (sy_call_t *)sys_rename;
|
||||
freebsd32_sysent[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
|
||||
freebsd32_sysent[FREEBSD32_SYS_link].sy_call = (sy_call_t *)sys_link;
|
||||
freebsd32_sysent[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
|
||||
freebsd32_sysent[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
|
||||
#endif /* COMPAT_FREEBSD32 */
|
||||
|
||||
EVENTHANDLER_DEREGISTER(process_exec, filemon_exec_tag);
|
||||
EVENTHANDLER_DEREGISTER(process_exit, filemon_exit_tag);
|
||||
|
@ -110,7 +110,7 @@ SUBDIR= \
|
||||
fdc \
|
||||
fdescfs \
|
||||
${_fe} \
|
||||
${_filemon} \
|
||||
filemon \
|
||||
firewire \
|
||||
firmware \
|
||||
fuse \
|
||||
@ -388,7 +388,6 @@ SUBDIR= \
|
||||
zlib \
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
|
||||
_filemon= filemon
|
||||
_imgact_binmisc= imgact_binmisc
|
||||
_vmware= vmware
|
||||
.endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user