Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/ultrix Switch ultrix_sys_getmnt() to mountlist it...
details: https://anonhg.NetBSD.org/src/rev/e038b2ec8952
branches: trunk
changeset: 352871:e038b2ec8952
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Apr 13 09:18:18 2017 +0000
description:
Switch ultrix_sys_getmnt() to mountlist iterator.
Really skip "start" items instead of a useless loop.
Compile tested only.
diffstat:
sys/compat/ultrix/ultrix_fs.c | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
diffs (97 lines):
diff -r 3606144a861a -r e038b2ec8952 sys/compat/ultrix/ultrix_fs.c
--- a/sys/compat/ultrix/ultrix_fs.c Thu Apr 13 09:17:55 2017 +0000
+++ b/sys/compat/ultrix/ultrix_fs.c Thu Apr 13 09:18:18 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ultrix_fs.c,v 1.56 2015/10/23 19:40:11 maxv Exp $ */
+/* $NetBSD: ultrix_fs.c,v 1.57 2017/04/13 09:18:18 hannken Exp $ */
/*
* Copyright (c) 1995, 1997 Jonathan Stone
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.56 2015/10/23 19:40:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.57 2017/04/13 09:18:18 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -206,9 +206,10 @@
int
ultrix_sys_getmnt(struct lwp *l, const struct ultrix_sys_getmnt_args *uap, register_t *retval)
{
- struct mount *mp, *nmp;
+ struct mount *mp;
struct statvfs *sp;
struct ultrix_fs_data *sfsp;
+ mount_iterator_t *iter;
char *path;
int mntflags;
int skip;
@@ -216,7 +217,6 @@
long count, maxcount;
int error;
- nmp = NULL; /* XXX keep gcc quiet */
path = NULL;
error = 0;
maxcount = SCARG(uap, bufsize) / sizeof(struct ultrix_fs_data);
@@ -237,6 +237,7 @@
if ((error = copyinstr(SCARG(uap, path), path,
MAXPATHLEN, NULL)) != 0)
goto bad;
+ skip = 0;
maxcount = 1;
} else {
/*
@@ -247,20 +248,14 @@
if ((error = copyin((void *)SCARG(uap, start), &start,
sizeof(*SCARG(uap, start)))) != 0)
goto bad;
- mutex_enter(&mountlist_lock);
- for (skip = start, mp = TAILQ_FIRST(&mountlist);
- mp != NULL && skip-- > 0;
- mp = TAILQ_NEXT(mp, mnt_list))
- continue;
- mutex_exit(&mountlist_lock);
+ skip = start;
}
- mutex_enter(&mountlist_lock);
- for (count = 0, mp = TAILQ_FIRST(&mountlist);
- mp != NULL && count < maxcount; mp = nmp) {
- if (vfs_busy(mp, &nmp)) {
+ count = 0;
+ mountlist_iterator_init(&iter);
+ while (count < maxcount && (mp = mountlist_iterator_next(iter))) {
+ if (skip-- > 0)
continue;
- }
if (sfsp != NULL) {
struct ultrix_fs_data tem;
sp = &mp->mnt_stat;
@@ -281,16 +276,13 @@
make_ultrix_mntent(sp, &tem);
if ((error = copyout((void *)&tem, sfsp,
sizeof(tem))) != 0) {
- vfs_unbusy(mp, false, NULL);
goto bad;
}
sfsp++;
count++;
}
}
- vfs_unbusy(mp, false, &nmp);
}
- mutex_exit(&mountlist_lock);
if (sfsp != NULL && count > maxcount)
*retval = maxcount;
@@ -298,6 +290,7 @@
*retval = count;
bad:
+ mountlist_iterator_destroy(iter);
if (path)
free(path, M_TEMP);
return error;
Home |
Main Index |
Thread Index |
Old Index