From owner-svn-src-head@FreeBSD.ORG Wed Jul 10 15:35:26 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0B2E0595; Wed, 10 Jul 2013 15:35:26 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E217E17C6; Wed, 10 Jul 2013 15:35:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFZPCM085209; Wed, 10 Jul 2013 15:35:25 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AFZPY2085207; Wed, 10 Jul 2013 15:35:25 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201307101535.r6AFZPY2085207@svn.freebsd.org> From: Marcel Moolenaar Date: Wed, 10 Jul 2013 15:35:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253158 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:35:26 -0000 Author: marcel Date: Wed Jul 10 15:35:25 2013 New Revision: 253158 URL: http://svnweb.freebsd.org/changeset/base/253158 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. This change differs from r253224 in the following way: o The vfs_mounted handler is called before mountcheckdirs() and with newdp locked. vp is unlocked. o The event handlers are declared in and not in . The header is used in user land code that pretends to be kernel code and as such creates a very convoluted environment. It's hard to untangle. Submitted by: stevek@juniper.net Discussed with: pjd@ Obtained from: Juniper Networks, Inc. Modified: head/sys/kern/vfs_mount.c head/sys/sys/eventhandler.h Modified: head/sys/kern/vfs_mount.c ============================================================================== --- head/sys/kern/vfs_mount.c Wed Jul 10 14:16:39 2013 (r253157) +++ head/sys/kern/vfs_mount.c Wed Jul 10 15:35:25 2013 (r253158) @@ -861,8 +861,9 @@ vfs_domount_first( vfs_event_signal(NULL, VQ_MOUNT, 0); if (VFS_ROOT(mp, LK_EXCLUSIVE, &newdp)) panic("mount: lost mount"); - VOP_UNLOCK(newdp, 0); VOP_UNLOCK(vp, 0); + EVENTHANDLER_INVOKE(vfs_mounted, mp, newdp, td); + VOP_UNLOCK(newdp, 0); mountcheckdirs(vp, newdp); vrele(newdp); if ((mp->mnt_flag & MNT_RDONLY) == 0) @@ -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/eventhandler.h ============================================================================== --- head/sys/sys/eventhandler.h Wed Jul 10 14:16:39 2013 (r253157) +++ head/sys/sys/eventhandler.h Wed Jul 10 15:35:25 2013 (r253158) @@ -192,6 +192,17 @@ EVENTHANDLER_DECLARE(vm_lowmem, vm_lowme typedef void (*mountroot_handler_t)(void *); EVENTHANDLER_DECLARE(mountroot, mountroot_handler_t); +/* File system mount events */ +struct mount; +struct vnode; +struct thread; +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); + /* VLAN state change events */ struct ifnet; typedef void (*vlan_config_fn)(void *, struct ifnet *, uint16_t); @@ -231,7 +242,6 @@ EVENTHANDLER_DECLARE(process_exec, execl /* * application dump event */ -struct thread; typedef void (*app_coredump_start_fn)(void *, struct thread *, char *name); typedef void (*app_coredump_progress_fn)(void *, struct thread *td, int byte_count); typedef void (*app_coredump_finish_fn)(void *, struct thread *td);