summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-08-18 13:36:09 +0000
committerdes <des@FreeBSD.org>2003-08-18 13:36:09 +0000
commit6169ee96f23dec2a698ec7cebfed6fc91b198c9d (patch)
tree7c1d03da4d82fc7d9b6d4e2a34dae2c1bd40f64c /sys/fs
parent1bccee947e37f6a13b02de89c61a8031d9eabf1f (diff)
downloadFreeBSD-src-6169ee96f23dec2a698ec7cebfed6fc91b198c9d.zip
FreeBSD-src-6169ee96f23dec2a698ec7cebfed6fc91b198c9d.tar.gz
Rework pfs_iterate() a bit to eliminate a bug related to process
directories. Previously, pfs_iterate() would return -1 when it reached the end of the process list while processing a process directory node, even if the parent directory contained further nodes (which is the case for the linprocfs root directory, where the process directory node is actually first in the list). With this patch, pfs_iterate() will continue to traverse the parent directory's node list after exhausting the process list (as was the intention all along). The code should hopefully be easier to read as well. While I'm here, have pfs_iterate() assert that the allproc lock is held.
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/pseudofs/pseudofs_vnops.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c
index 3cdd21a..93aa23c 100644
--- a/sys/fs/pseudofs/pseudofs_vnops.c
+++ b/sys/fs/pseudofs/pseudofs_vnops.c
@@ -543,21 +543,24 @@ static int
pfs_iterate(struct thread *td, pid_t pid, struct pfs_node *pd,
struct pfs_node **pn, struct proc **p)
{
- if ((*pn) == NULL)
- *pn = pd->pn_nodes;
- else
+ mtx_assert(&allproc, MA_OWNED);
again:
- if ((*pn)->pn_type != pfstype_procdir)
+ if (*pn == NULL) {
+ /* first node */
+ *pn = pd->pn_nodes;
+ } else if ((*pn)->pn_type != pfstype_procdir) {
+ /* next node */
*pn = (*pn)->pn_next;
-
- while (*pn != NULL && (*pn)->pn_type == pfstype_procdir) {
+ }
+ if (*pn != NULL && (*pn)->pn_type == pfstype_procdir) {
+ /* next process */
if (*p == NULL)
*p = LIST_FIRST(&allproc);
else
*p = LIST_NEXT(*p, p_list);
- if (*p != NULL)
- break;
- *pn = (*pn)->pn_next;
+ /* out of processes: next node */
+ if (*p == NULL)
+ *pn = (*pn)->pn_next;
}
if ((*pn) == NULL)
OpenPOWER on IntegriCloud