Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Switch veriexec_dump() and veriexec_flush() to moun...



details:   https://anonhg.NetBSD.org/src/rev/4f62788ce42b
branches:  trunk
changeset: 823097:4f62788ce42b
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed Apr 12 10:30:02 2017 +0000

description:
Switch veriexec_dump() and veriexec_flush() to mountlist iterator.

diffstat:

 sys/kern/kern_veriexec.c |  34 ++++++++++++----------------------
 1 files changed, 12 insertions(+), 22 deletions(-)

diffs (74 lines):

diff -r 1ff3a506561d -r 4f62788ce42b sys/kern/kern_veriexec.c
--- a/sys/kern/kern_veriexec.c  Wed Apr 12 10:28:39 2017 +0000
+++ b/sys/kern/kern_veriexec.c  Wed Apr 12 10:30:02 2017 +0000
@@ -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 <elad%NetBSD.org@localhost>
@@ -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 @@
 int
 veriexec_dump(struct lwp *l, prop_array_t rarray)
 {
-       struct mount *mp, *nmp;
+       mount_iterator_t *iter;
+       struct mount *mp;
 
-       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;
-
+       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 @@
 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);
 }



Home | Main Index | Thread Index | Old Index