Module Name: src
Committed By: hannken
Date: Thu Apr 13 09:41:28 UTC 2017
Modified Files:
src/sys/compat/common: vfs_syscalls_20.c
Log Message:
Switch compat_20_sys_getfsstat() to mountlist iterator.
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/compat/common/vfs_syscalls_20.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/compat/common/vfs_syscalls_20.c
diff -u src/sys/compat/common/vfs_syscalls_20.c:1.39 src/sys/compat/common/vfs_syscalls_20.c:1.40
--- src/sys/compat/common/vfs_syscalls_20.c:1.39 Fri Jul 24 13:02:52 2015
+++ src/sys/compat/common/vfs_syscalls_20.c Thu Apr 13 09:41:28 2017
@@ -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 @@ compat_20_sys_getfsstat(struct lwp *l, c
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 @@ compat_20_sys_getfsstat(struct lwp *l, c
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 @@ compat_20_sys_getfsstat(struct lwp *l, c
else
*retval = count;
out:
+ mountlist_iterator_destroy(iter);
free(sbuf, M_TEMP);
return error;
}