Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/pseudofs/pseudofs_vnops.c
Show First 20 Lines • Show All 803 Lines • ▼ Show 20 Lines | pfs_readdir(struct vop_readdir_args *va) | ||||
offset = uio->uio_offset; | offset = uio->uio_offset; | ||||
resid = uio->uio_resid; | resid = uio->uio_resid; | ||||
if (offset < 0 || offset % PFS_DELEN != 0 || | if (offset < 0 || offset % PFS_DELEN != 0 || | ||||
(resid && resid < PFS_DELEN)) | (resid && resid < PFS_DELEN)) | ||||
PFS_RETURN (EINVAL); | PFS_RETURN (EINVAL); | ||||
if (resid == 0) | if (resid == 0) | ||||
PFS_RETURN (0); | PFS_RETURN (0); | ||||
if (!pfs_lookup_proc(pid, &proc)) | proc = NULL; | ||||
if (pid != NO_PID && !pfs_lookup_proc(pid, &proc)) | |||||
PFS_RETURN (ENOENT); | PFS_RETURN (ENOENT); | ||||
sx_slock(&allproc_lock); | sx_slock(&allproc_lock); | ||||
pfs_lock(pd); | pfs_lock(pd); | ||||
KASSERT(pid == NO_PID || proc != NULL, | |||||
("%s(): no process for pid %lu", __func__, (unsigned long)pid)); | |||||
if (pid != NO_PID) { | |||||
PROC_LOCK(proc); | PROC_LOCK(proc); | ||||
/* check if the directory is visible to the caller */ | /* check if the directory is visible to the caller */ | ||||
if (!pfs_visible_proc(curthread, pd, proc)) { | if (!pfs_visible_proc(curthread, pd, proc)) { | ||||
_PRELE(proc); | _PRELE(proc); | ||||
PROC_UNLOCK(proc); | PROC_UNLOCK(proc); | ||||
sx_sunlock(&allproc_lock); | sx_sunlock(&allproc_lock); | ||||
pfs_unlock(pd); | pfs_unlock(pd); | ||||
PFS_RETURN (ENOENT); | PFS_RETURN (ENOENT); | ||||
} | } | ||||
KASSERT(pid == NO_PID || proc != NULL, | } | ||||
("%s(): no process for pid %lu", __func__, (unsigned long)pid)); | |||||
/* skip unwanted entries */ | /* skip unwanted entries */ | ||||
for (pn = NULL, p = NULL; offset > 0; offset -= PFS_DELEN) { | for (pn = NULL, p = NULL; offset > 0; offset -= PFS_DELEN) { | ||||
if (pfs_iterate(curthread, proc, pd, &pn, &p) == -1) { | if (pfs_iterate(curthread, proc, pd, &pn, &p) == -1) { | ||||
/* nothing left... */ | /* nothing left... */ | ||||
if (proc != NULL) { | if (proc != NULL) { | ||||
_PRELE(proc); | _PRELE(proc); | ||||
PROC_UNLOCK(proc); | PROC_UNLOCK(proc); | ||||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |