Module Name:    src
Committed By:   hannken
Date:           Thu Apr 13 09:18:18 UTC 2017

Modified Files:
        src/sys/compat/ultrix: ultrix_fs.c

Log Message:
Switch ultrix_sys_getmnt() to mountlist iterator.
Really skip "start" items instead of a useless loop.
Compile tested only.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/compat/ultrix/ultrix_fs.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/ultrix/ultrix_fs.c
diff -u src/sys/compat/ultrix/ultrix_fs.c:1.56 src/sys/compat/ultrix/ultrix_fs.c:1.57
--- src/sys/compat/ultrix/ultrix_fs.c:1.56	Fri Oct 23 19:40:11 2015
+++ src/sys/compat/ultrix/ultrix_fs.c	Thu Apr 13 09:18:18 2017
@@ -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 @@ make_ultrix_mntent(struct statvfs *sp, s
 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 @@ ultrix_sys_getmnt(struct lwp *l, const s
 	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 @@ ultrix_sys_getmnt(struct lwp *l, const s
 		if ((error = copyinstr(SCARG(uap, path), path,
 				       MAXPATHLEN, NULL)) != 0)
 			goto bad;
+		skip = 0;
 		maxcount = 1;
 	} else {
 		/*
@@ -247,20 +248,14 @@ ultrix_sys_getmnt(struct lwp *l, const s
 		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 @@ ultrix_sys_getmnt(struct lwp *l, const s
 				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 @@ ultrix_sys_getmnt(struct lwp *l, const s
 		*retval = count;
 
 bad:
+	mountlist_iterator_destroy(iter);
 	if (path)
 		free(path, M_TEMP);
 	return error;

Reply via email to