Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jun 2013 23:51:27 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r251590 - in head/sys: kern sys
Message-ID:  <201306092351.r59NpRTZ024888@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sun Jun  9 23:51:26 2013
New Revision: 251590
URL: http://svnweb.freebsd.org/changeset/base/251590

Log:
  Add vfs_mounted and vfs_unmounted events so that components can be informed
  about mount and unmount events. This is used by Juniper to implement a more
  optimal implementation of NetBSD's veriexec.
  
  Submitted by:	stevek@juniper.net
  Obtained from:	Juniper Networks, Inc

Modified:
  head/sys/kern/vfs_mount.c
  head/sys/sys/mount.h

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Sun Jun  9 23:50:30 2013	(r251589)
+++ head/sys/kern/vfs_mount.c	Sun Jun  9 23:51:26 2013	(r251590)
@@ -864,6 +864,7 @@ vfs_domount_first(
 	VOP_UNLOCK(newdp, 0);
 	VOP_UNLOCK(vp, 0);
 	mountcheckdirs(vp, newdp);
+	EVENTHANDLER_INVOKE(vfs_mounted, mp, newdp, td);
 	vrele(newdp);
 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
 		vfs_allocate_syncvnode(mp);
@@ -1355,6 +1356,7 @@ dounmount(mp, flags, td)
 	mtx_lock(&mountlist_mtx);
 	TAILQ_REMOVE(&mountlist, mp, mnt_list);
 	mtx_unlock(&mountlist_mtx);
+	EVENTHANDLER_INVOKE(vfs_unmounted, mp, td);
 	if (coveredvp != NULL) {
 		coveredvp->v_mountedhere = NULL;
 		vput(coveredvp);

Modified: head/sys/sys/mount.h
==============================================================================
--- head/sys/sys/mount.h	Sun Jun  9 23:50:30 2013	(r251589)
+++ head/sys/sys/mount.h	Sun Jun  9 23:51:26 2013	(r251590)
@@ -39,6 +39,7 @@
 #include <sys/lock.h>
 #include <sys/lockmgr.h>
 #include <sys/_mutex.h>
+#include <sys/eventhandler.h>
 #endif
 
 /*
@@ -798,6 +799,17 @@ vfs_statfs_t	__vfs_statfs;
 extern	char *mountrootfsname;
 
 /*
+ * Event handlers
+ */
+
+typedef void (*vfs_mounted_notify_fn)(void *, struct mount *, struct vnode *,
+    struct thread *);
+typedef void (*vfs_unmounted_notify_fn)(void *, struct mount *,
+    struct thread *);
+EVENTHANDLER_DECLARE(vfs_mounted, vfs_mounted_notify_fn);
+EVENTHANDLER_DECLARE(vfs_unmounted, vfs_unmounted_notify_fn);
+
+/*
  * exported vnode operations
  */
 



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