Module Name: src Committed By: hannken Date: Wed Apr 12 10:30:02 UTC 2017
Modified Files: src/sys/kern: kern_veriexec.c Log Message: Switch veriexec_dump() and veriexec_flush() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/kern/kern_veriexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_veriexec.c diff -u src/sys/kern/kern_veriexec.c:1.11 src/sys/kern/kern_veriexec.c:1.12 --- src/sys/kern/kern_veriexec.c:1.11 Tue Aug 4 12:44:04 2015 +++ src/sys/kern/kern_veriexec.c Wed Apr 12 10:30:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_veriexec.c,v 1.11 2015/08/04 12:44:04 maxv Exp $ */ +/* $NetBSD: kern_veriexec.c,v 1.12 2017/04/12 10:30:02 hannken Exp $ */ /*- * Copyright (c) 2005, 2006 Elad Efrat <e...@netbsd.org> @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.11 2015/08/04 12:44:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.12 2017/04/12 10:30:02 hannken Exp $"); #include "opt_veriexec.h" @@ -1363,20 +1363,15 @@ veriexec_file_dump(struct veriexec_file_ int veriexec_dump(struct lwp *l, prop_array_t rarray) { - struct mount *mp, *nmp; - - mutex_enter(&mountlist_lock); - for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { - /* If it fails, the file-system is [being] unmounted. */ - if (vfs_busy(mp, &nmp) != 0) - continue; + mount_iterator_t *iter; + struct mount *mp; + mountlist_iterator_init(&iter); + while ((mp = mountlist_iterator_next(iter)) != NULL) { fileassoc_table_run(mp, veriexec_hook, (fileassoc_cb_t)veriexec_file_dump, rarray); - - vfs_unbusy(mp, false, &nmp); } - mutex_exit(&mountlist_lock); + mountlist_iterator_destroy(iter); return (0); } @@ -1384,24 +1379,19 @@ veriexec_dump(struct lwp *l, prop_array_ int veriexec_flush(struct lwp *l) { - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; int error = 0; - mutex_enter(&mountlist_lock); - for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { + mountlist_iterator_init(&iter); + while ((mp = mountlist_iterator_next(iter)) != NULL) { int lerror; - /* If it fails, the file-system is [being] unmounted. */ - if (vfs_busy(mp, &nmp) != 0) - continue; - lerror = veriexec_table_delete(l, mp); if (lerror && lerror != ENOENT) error = lerror; - - vfs_unbusy(mp, false, &nmp); } - mutex_exit(&mountlist_lock); + mountlist_iterator_destroy(iter); return (error); }