Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Switch compat_20_netbsd32_getfsstat() to...



details:   https://anonhg.NetBSD.org/src/rev/c2e781d64fcc
branches:  trunk
changeset: 823126:c2e781d64fcc
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Apr 13 09:46:59 2017 +0000

description:
Switch compat_20_netbsd32_getfsstat() to mountlist iterator.

diffstat:

 sys/compat/netbsd32/netbsd32_compat_20.c |  22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diffs (72 lines):

diff -r c239b4d6bd1e -r c2e781d64fcc sys/compat/netbsd32/netbsd32_compat_20.c
--- a/sys/compat/netbsd32/netbsd32_compat_20.c  Thu Apr 13 09:44:48 2017 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_20.c  Thu Apr 13 09:46:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_compat_20.c,v 1.35 2017/03/28 18:44:04 chs Exp $      */
+/*     $NetBSD: netbsd32_compat_20.c,v 1.36 2017/04/13 09:46:59 hannken Exp $  */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.35 2017/03/28 18:44:04 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.36 2017/04/13 09:46:59 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,7 +85,8 @@
        } */
        int root = 0;
        struct proc *p = l->l_proc;
-       struct mount *mp, *nmp;
+       mount_iterator_t *iter;
+       struct mount *mp;
        struct statvfs *sb;
        struct netbsd32_statfs sb32;
        void *sfsp;
@@ -95,32 +96,24 @@
        sb = STATVFSBUF_GET();
        maxcount = SCARG(uap, bufsize) / sizeof(struct netbsd32_statfs);
        sfsp = SCARG_P32(uap, buf);
-       mutex_enter(&mountlist_lock);
+       mountlist_iterator_init(&iter);
        count = 0;
-       for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
-               if (vfs_busy(mp, &nmp)) {
-                       continue;
-               }
+       while ((mp = mountlist_iterator_next(iter)) != NULL) {
                if (sfsp && count < maxcount) {
                        error = dostatvfs(mp, sb, l, SCARG(uap, flags), 0);
                        if (error) {
-                               vfs_unbusy(mp, false, &nmp);
                                error = 0;
                                continue;
                        }
                        compat_20_netbsd32_from_statvfs(sb, &sb32);
                        error = copyout(&sb32, sfsp, sizeof(sb32));
-                       if (error) {
-                               vfs_unbusy(mp, false, NULL);
+                       if (error)
                                goto out;
-                       }
                        sfsp = (char *)sfsp + sizeof(sb32);
                        root |= strcmp(sb->f_mntonname, "/") == 0;
                }
                count++;
-               vfs_unbusy(mp, false, &nmp);
        }
-       mutex_exit(&mountlist_lock);
 
        if (root == 0 && p->p_cwdi->cwdi_rdir) {
                /*
@@ -144,6 +137,7 @@
        else
                *retval = count;
 out:
+       mountlist_iterator_destroy(iter);
        STATVFSBUF_PUT(sb);
        return error;
 }



Home | Main Index | Thread Index | Old Index