Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jun 2016 20:32:34 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r302072 - in stable/10/sys: dev/filemon modules
Message-ID:  <201606212032.u5LKWYCF042588@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Tue Jun 21 20:32:34 2016
New Revision: 302072
URL: https://svnweb.freebsd.org/changeset/base/302072

Log:
  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.

Modified:
  stable/10/sys/dev/filemon/filemon.c
  stable/10/sys/dev/filemon/filemon_wrapper.c
  stable/10/sys/modules/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/filemon/filemon.c
==============================================================================
--- stable/10/sys/dev/filemon/filemon.c	Tue Jun 21 20:28:30 2016	(r302071)
+++ stable/10/sys/dev/filemon/filemon.c	Tue Jun 21 20:32:34 2016	(r302072)
@@ -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 c
 		    &filemon->fp);
 		if (error == 0)
 			/* Write the file header. */
-			filemon_comment(filemon);
+			filemon_write_header(filemon);
 		break;
 
 	/* Set the monitored process ID. */

Modified: stable/10/sys/dev/filemon/filemon_wrapper.c
==============================================================================
--- stable/10/sys/dev/filemon/filemon_wrapper.c	Tue Jun 21 20:28:30 2016	(r302071)
+++ stable/10/sys/dev/filemon/filemon_wrapper.c	Tue Jun 21 20:32:34 2016	(r302072)
@@ -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, 
 		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 __u
 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;
-
-#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 */
+
+	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_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;
-
-#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 */
+
+	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_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);

Modified: stable/10/sys/modules/Makefile
==============================================================================
--- stable/10/sys/modules/Makefile	Tue Jun 21 20:28:30 2016	(r302071)
+++ stable/10/sys/modules/Makefile	Tue Jun 21 20:32:34 2016	(r302072)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606212032.u5LKWYCF042588>