Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/common Switch compat_20_sys_getfsstat() to mountl...



details:   https://anonhg.NetBSD.org/src/rev/a25de7a2c794
branches:  trunk
changeset: 823124:a25de7a2c794
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Apr 13 09:41:28 2017 +0000

description:
Switch compat_20_sys_getfsstat() to mountlist iterator.

diffstat:

 sys/compat/common/vfs_syscalls_20.c |  25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diffs (71 lines):

diff -r de24a7e4a2c6 -r a25de7a2c794 sys/compat/common/vfs_syscalls_20.c
--- a/sys/compat/common/vfs_syscalls_20.c       Thu Apr 13 09:25:33 2017 +0000
+++ b/sys/compat/common/vfs_syscalls_20.c       Thu Apr 13 09:41:28 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_20.c,v 1.39 2015/07/24 13:02:52 maxv Exp $        */
+/*     $NetBSD: vfs_syscalls_20.c,v 1.40 2017/04/13 09:41:28 hannken Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.39 2015/07/24 13:02:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.40 2017/04/13 09:41:28 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -203,7 +203,8 @@
                syscallarg(int) flags;
        } */
        int root = 0;
-       struct mount *mp, *nmp;
+       mount_iterator_t *iter;
+       struct mount *mp;
        struct statvfs *sbuf;
        struct statfs12 *sfsp;
        size_t count, maxcount;
@@ -212,30 +213,21 @@
        sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK);
        maxcount = (size_t)SCARG(uap, bufsize) / sizeof(struct statfs12);
        sfsp = SCARG(uap, buf);
-       mutex_enter(&mountlist_lock);
        count = 0;
-       for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
-               if (vfs_busy(mp, &nmp)) {
-                       continue;
-               }
+       mountlist_iterator_init(&iter);
+       while ((mp = mountlist_iterator_next(iter)) != NULL) {
                if (sfsp && count < maxcount) {
                        error = dostatvfs(mp, sbuf, l, SCARG(uap, flags), 0);
-                       if (error) {
-                               vfs_unbusy(mp, false, &nmp);
+                       if (error) 
                                continue;
-                       }
                        error = vfs2fs(sfsp, sbuf);
-                       if (error) {
-                               vfs_unbusy(mp, false, NULL);
+                       if (error)
                                goto out;
-                       }
                        sfsp++;
                        root |= strcmp(sbuf->f_mntonname, "/") == 0;
                }
                count++;
-               vfs_unbusy(mp, false, &nmp);
        }
-       mutex_exit(&mountlist_lock);
        if (root == 0 && l->l_proc->p_cwdi->cwdi_rdir) {
                /*
                 * fake a root entry
@@ -252,6 +244,7 @@
        else
                *retval = count;
 out:
+       mountlist_iterator_destroy(iter);
        free(sbuf, M_TEMP);
        return error;
 }



Home | Main Index | Thread Index | Old Index