svn commit: r351815 - head/sys/fs/pseudofs
Kyle Evans
kevans at FreeBSD.org
Wed Sep 4 14:20:40 UTC 2019
Author: kevans
Date: Wed Sep 4 14:20:39 2019
New Revision: 351815
URL: https://svnweb.freebsd.org/changeset/base/351815
Log:
pseudofs: make readdir work without a pid again
Specifically, the following was broken:
$ mount -t procfs procfs /proc
$ ls -l /proc
r351741 reworked readdir slightly to avoid pfs_node/pidhash LOR, but
inadvertently regressed pid == NO_PID; new pfs_lookup_proc() fails for the
obvious reasons, and later pfs_visible_proc doesn't capture the
pid == NO_PID -> return 1 aspect of pfs_visible. We can infact skip this
whole block if we're operating on a directory w/ NO_PID, as it's always
visible.
Reported by: trasz
Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D21518
Modified:
head/sys/fs/pseudofs/pseudofs_vnops.c
Modified: head/sys/fs/pseudofs/pseudofs_vnops.c
==============================================================================
--- head/sys/fs/pseudofs/pseudofs_vnops.c Wed Sep 4 14:05:04 2019 (r351814)
+++ head/sys/fs/pseudofs/pseudofs_vnops.c Wed Sep 4 14:20:39 2019 (r351815)
@@ -809,23 +809,28 @@ pfs_readdir(struct vop_readdir_args *va)
if (resid == 0)
PFS_RETURN (0);
- if (!pfs_lookup_proc(pid, &proc))
+ proc = NULL;
+ if (pid != NO_PID && !pfs_lookup_proc(pid, &proc))
PFS_RETURN (ENOENT);
sx_slock(&allproc_lock);
pfs_lock(pd);
- PROC_LOCK(proc);
- /* check if the directory is visible to the caller */
- if (!pfs_visible_proc(curthread, pd, proc)) {
- _PRELE(proc);
- PROC_UNLOCK(proc);
- sx_sunlock(&allproc_lock);
- pfs_unlock(pd);
- PFS_RETURN (ENOENT);
- }
KASSERT(pid == NO_PID || proc != NULL,
("%s(): no process for pid %lu", __func__, (unsigned long)pid));
+
+ if (pid != NO_PID) {
+ PROC_LOCK(proc);
+
+ /* check if the directory is visible to the caller */
+ if (!pfs_visible_proc(curthread, pd, proc)) {
+ _PRELE(proc);
+ PROC_UNLOCK(proc);
+ sx_sunlock(&allproc_lock);
+ pfs_unlock(pd);
+ PFS_RETURN (ENOENT);
+ }
+ }
/* skip unwanted entries */
for (pn = NULL, p = NULL; offset > 0; offset -= PFS_DELEN) {
More information about the svn-src-all
mailing list