diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index f2e5d2ba36e1..f2cf37d58112 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -426,7 +426,7 @@ linprocfs_domtab(PFS_FILL_ARGS) error = namei(&nd); lep = linux_emul_path; if (error == 0) { - if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0) + if (vn_fullpath(nd.ni_vp, &dlep, &flep) == 0) lep = dlep; vrele(nd.ni_vp); } @@ -1053,7 +1053,7 @@ linprocfs_doproccwd(PFS_FILL_ARGS) char *freepath = NULL; pwd = pwd_hold(td); - vn_fullpath(td, pwd->pwd_cdir, &fullpath, &freepath); + vn_fullpath(pwd->pwd_cdir, &fullpath, &freepath); sbuf_printf(sb, "%s", fullpath); if (freepath) free(freepath, M_TEMP); @@ -1074,7 +1074,7 @@ linprocfs_doprocroot(PFS_FILL_ARGS) pwd = pwd_hold(td); vp = jailed(p->p_ucred) ? pwd->pwd_jdir : pwd->pwd_rdir; - vn_fullpath(td, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); sbuf_printf(sb, "%s", fullpath); if (freepath) free(freepath, M_TEMP); @@ -1219,7 +1219,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(td, vp, &name, &freename); + vn_fullpath(vp, &name, &freename); vn_lock(vp, LK_SHARED | LK_RETRY); VOP_GETATTR(vp, &vat, td->td_ucred); ino = vat.va_fileid; diff --git a/sys/compat/linux/linux_getcwd.c b/sys/compat/linux/linux_getcwd.c index 68812f605a91..c39e69c4e707 100644 --- a/sys/compat/linux/linux_getcwd.c +++ b/sys/compat/linux/linux_getcwd.c @@ -73,7 +73,7 @@ linux_getcwd(struct thread *td, struct linux_getcwd_args *uap) buflen = LINUX_PATH_MAX; buf = malloc(buflen, M_TEMP, M_WAITOK); - error = vn_getcwd(td, buf, &retbuf, &buflen); + error = vn_getcwd(buf, &retbuf, &buflen); if (error == 0) { error = copyout(retbuf, uap->buf, buflen); if (error == 0) diff --git a/sys/dev/filemon/filemon_wrapper.c b/sys/dev/filemon/filemon_wrapper.c index 8f76de68eba9..52dd3bb483eb 100644 --- a/sys/dev/filemon/filemon_wrapper.c +++ b/sys/dev/filemon/filemon_wrapper.c @@ -186,8 +186,7 @@ _filemon_wrapper_openat(struct thread *td, const char *upath, int flags, */ if (getvnode(td, fd, cap_rights_init(&rights, CAP_LOOKUP), &fp) == 0) { - vn_fullpath(td, fp->f_vnode, &atpath, - &freepath); + vn_fullpath(fp->f_vnode, &atpath, &freepath); } } if (flags & O_RDWR) { diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 3e4f0de2c7e4..6f7753dd11c1 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -832,7 +832,7 @@ pmc_getfilename(struct vnode *v, char **fullpath, char **freepath) *fullpath = "unknown"; *freepath = NULL; - vn_fullpath(curthread, v, fullpath, freepath); + vn_fullpath(v, fullpath, freepath); } /* diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 87fcb7160bbb..f6f08caa4eba 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -640,7 +640,7 @@ fdesc_readlink(struct vop_readlink_args *va) switch (fp->f_type) { case DTYPE_VNODE: vp = fp->f_vnode; - error = vn_fullpath(td, vp, &fullpath, &freepath); + error = vn_fullpath(vp, &fullpath, &freepath); break; default: fullpath = "anon_inode:[unknown]"; diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index 92208497231e..3aac34c2b8d9 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -79,7 +79,7 @@ procfs_doprocfile(PFS_FILL_ARGS) textvp = p->p_textvp; vhold(textvp); PROC_UNLOCK(p); - error = vn_fullpath(td, textvp, &fullpath, &freepath); + error = vn_fullpath(textvp, &fullpath, &freepath); vdrop(textvp); if (error == 0) sbuf_printf(sb, "%s", fullpath); diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c index 2bd8aab00457..a9893e5e10f0 100644 --- a/sys/fs/procfs/procfs_map.c +++ b/sys/fs/procfs/procfs_map.c @@ -189,7 +189,7 @@ procfs_doprocmap(PFS_FILL_ARGS) shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(td, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); vrele(vp); } } else { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 6bad0beb15e8..926633e4e55d 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -575,8 +575,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p) imgp->execpath = args->fname; else { VOP_UNLOCK(imgp->vp); - if (vn_fullpath(td, imgp->vp, &imgp->execpath, - &imgp->freepath) != 0) + if (vn_fullpath(imgp->vp, &imgp->execpath, &imgp->freepath) != 0) imgp->execpath = args->fname; vn_lock(imgp->vp, LK_SHARED | LK_RETRY); } diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2383b9e069db..af7357dc790b 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2237,7 +2237,7 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) vref(vp); if (*pidp != -1) PROC_UNLOCK(p); - error = vn_fullpath(req->td, vp, &retbuf, &freebuf); + error = vn_fullpath(vp, &retbuf, &freebuf); vrele(vp); if (error) return (error); @@ -2375,8 +2375,7 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS) kve->kve_shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(curthread, vp, &fullpath, - &freepath); + vn_fullpath(vp, &fullpath, &freepath); cred = curthread->td_ucred; vn_lock(vp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(vp, &va, cred) == 0) { @@ -2584,8 +2583,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags) kve->kve_shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(curthread, vp, &fullpath, - &freepath); + vn_fullpath(vp, &fullpath, &freepath); kve->kve_vn_type = vntype_to_kinfo(vp->v_type); cred = curthread->td_ucred; vn_lock(vp, LK_SHARED | LK_RETRY); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 019526cd0d5e..d65532f5d50f 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -3731,7 +3731,7 @@ coredump(struct thread *td) if (error != 0 || coredump_devctl == 0) goto out; sb = sbuf_new_auto(); - if (vn_fullpath_global(td, p->p_textvp, &fullpath, &freepath) != 0) + if (vn_fullpath_global(p->p_textvp, &fullpath, &freepath) != 0) goto out2; sbuf_printf(sb, "comm=\""); devctl_safe_quote_sb(sb, fullpath); @@ -3746,7 +3746,7 @@ coredump(struct thread *td) if (name[0] != '/') { fullpathsize = MAXPATHLEN; freepath = malloc(fullpathsize, M_TEMP, M_WAITOK); - if (vn_getcwd(td, freepath, &fullpath, &fullpathsize) != 0) { + if (vn_getcwd(freepath, &fullpath, &fullpathsize) != 0) { free(freepath, M_TEMP); goto out2; } diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 9feb3c66f6f5..ca3eb046b6f1 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -418,7 +418,7 @@ ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve) if (vp != NULL) { freepath = NULL; fullpath = NULL; - vn_fullpath(td, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); vn_lock(vp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(vp, &vattr, td->td_ucred) == 0) { pve->pve_fileid = vattr.va_fileid; diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 69d562a21d8e..367f268b711f 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -475,12 +475,12 @@ STATNODE_COUNTER(shrinking_skipped, "Number of times shrinking was already in progress"); static void cache_zap_locked(struct namecache *ncp); -static int vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, +static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, size_t *buflen); -static int vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *buflen); -static int vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend); +static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, + char **retbuf, size_t *buflen); +static int vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char *buf, + char **retbuf, size_t *len, bool slash_prefixed, size_t addend); static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries"); @@ -2463,7 +2463,7 @@ sys___getcwd(struct thread *td, struct __getcwd_args *uap) buflen = MAXPATHLEN; buf = uma_zalloc(namei_zone, M_WAITOK); - error = vn_getcwd(td, buf, &retbuf, &buflen); + error = vn_getcwd(buf, &retbuf, &buflen); if (error == 0) error = copyout(retbuf, uap->buf, buflen); uma_zfree(namei_zone, buf); @@ -2471,13 +2471,13 @@ sys___getcwd(struct thread *td, struct __getcwd_args *uap) } int -vn_getcwd(struct thread *td, char *buf, char **retbuf, size_t *buflen) +vn_getcwd(char *buf, char **retbuf, size_t *buflen) { struct pwd *pwd; int error; - pwd = pwd_hold(td); - error = vn_fullpath_any(td, pwd->pwd_cdir, pwd->pwd_rdir, buf, retbuf, buflen); + pwd = pwd_hold(curthread); + error = vn_fullpath_any(pwd->pwd_cdir, pwd->pwd_rdir, buf, retbuf, buflen); pwd_drop(pwd); #ifdef KTRACE @@ -2501,7 +2501,7 @@ kern___realpathat(struct thread *td, int fd, const char *path, char *buf, pathseg, path, fd, &cap_fstat_rights, td); if ((error = namei(&nd)) != 0) return (error); - error = vn_fullpath_hardlink(td, &nd, &retbuf, &freebuf, &size); + error = vn_fullpath_hardlink(&nd, &retbuf, &freebuf, &size); if (error == 0) { error = copyout(retbuf, buf, size); free(freebuf, M_TEMP); @@ -2523,23 +2523,22 @@ sys___realpathat(struct thread *td, struct __realpathat_args *uap) * cache (if available) */ int -vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) +vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf) { struct pwd *pwd; char *buf; size_t buflen; int error; - if (__predict_false(vn == NULL)) + if (__predict_false(vp == NULL)) return (EINVAL); buflen = MAXPATHLEN; buf = malloc(buflen, M_TEMP, M_WAITOK); - pwd = pwd_hold(td); - error = vn_fullpath_any(td, vn, pwd->pwd_rdir, buf, retbuf, &buflen); + pwd = pwd_hold(curthread); + error = vn_fullpath_any(vp, pwd->pwd_rdir, buf, retbuf, &buflen); pwd_drop(pwd); - - if (!error) + if (error == 0) *freebuf = buf; else free(buf, M_TEMP); @@ -2553,19 +2552,18 @@ vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) * global root mount point. */ int -vn_fullpath_global(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf) +vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf) { char *buf; size_t buflen; int error; - if (__predict_false(vn == NULL)) + if (__predict_false(vp == NULL)) return (EINVAL); buflen = MAXPATHLEN; buf = malloc(buflen, M_TEMP, M_WAITOK); - error = vn_fullpath_any(td, vn, rootvnode, buf, retbuf, &buflen); - if (!error) + error = vn_fullpath_any(vp, rootvnode, buf, retbuf, &buflen); + if (error == 0) *freebuf = buf; else free(buf, M_TEMP); @@ -2661,8 +2659,8 @@ vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, size_t *buflen) * The vnode must be referenced. */ static int -vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend) +vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, + size_t *len, bool slash_prefixed, size_t addend) { #ifdef KDTRACE_HOOKS struct vnode *startvp = vp; @@ -2727,7 +2725,7 @@ vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, error, vp, NULL); break; } - error = vn_vptocnp(&vp, td->td_ucred, buf, &buflen); + error = vn_vptocnp(&vp, curthread->td_ucred, buf, &buflen); if (error) break; if (buflen == 0) { @@ -2772,8 +2770,8 @@ vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, * (in which case resolving fails) */ static int -vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *buflen) +vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, + size_t *buflen) { size_t orig_buflen; bool slash_prefixed; @@ -2789,7 +2787,7 @@ vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, if (vp->v_type != VDIR) { *buflen -= 1; buf[*buflen] = '\0'; - error = vn_vptocnp(&vp, td->td_ucred, buf, buflen); + error = vn_vptocnp(&vp, curthread->td_ucred, buf, buflen); if (error) return (error); if (*buflen == 0) { @@ -2801,7 +2799,7 @@ vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, slash_prefixed = true; } - return (vn_fullpath_dir(td, vp, rdir, buf, retbuf, buflen, slash_prefixed, + return (vn_fullpath_dir(vp, rdir, buf, retbuf, buflen, slash_prefixed, orig_buflen - *buflen)); } @@ -2818,8 +2816,8 @@ vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, * from the parent */ static int -vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, - char **freebuf, size_t *buflen) +vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, + size_t *buflen) { char *buf, *tmpbuf; struct pwd *pwd; @@ -2838,7 +2836,7 @@ vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, slash_prefixed = false; buf = malloc(*buflen, M_TEMP, M_WAITOK); - pwd = pwd_hold(td); + pwd = pwd_hold(curthread); addend = 0; vp = ndp->ni_vp; @@ -2883,7 +2881,7 @@ vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, } vref(vp); - error = vn_fullpath_dir(td, vp, pwd->pwd_rdir, buf, retbuf, buflen, + error = vn_fullpath_dir(vp, pwd->pwd_rdir, buf, retbuf, buflen, slash_prefixed, addend); if (error != 0) goto out_bad; @@ -2969,7 +2967,7 @@ vn_path_to_global_path(struct thread *td, struct vnode *vp, char *path, /* Construct global filesystem path from vp. */ VOP_UNLOCK(vp); - error = vn_fullpath_global(td, vp, &rpath, &fbuf); + error = vn_fullpath_global(vp, &rpath, &fbuf); if (error != 0) { vrele(vp); diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index c9366c24a3f2..9bfd077fff1e 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2513,7 +2513,7 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif) kif->kf_un.kf_file.kf_file_type = vntype_to_kinfo(vp->v_type); freepath = NULL; fullpath = "-"; - error = vn_fullpath(curthread, vp, &fullpath, &freepath); + error = vn_fullpath(vp, &fullpath, &freepath); if (error == 0) { strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path)); } diff --git a/sys/security/audit/audit_bsm_klib.c b/sys/security/audit/audit_bsm_klib.c index c8d602fb692c..31a9bf29265d 100644 --- a/sys/security/audit/audit_bsm_klib.c +++ b/sys/security/audit/audit_bsm_klib.c @@ -463,7 +463,7 @@ audit_canon_path_vp(struct thread *td, struct vnode *rdir, struct vnode *cdir, * on Darwin. As a result, this may need some additional attention * in the future. */ - error = vn_fullpath_global(td, vp, &rbuf, &fbuf); + error = vn_fullpath_global(vp, &rbuf, &fbuf); if (error) { cpath[0] = '\0'; return; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 6a6cb3d7a69a..76b7a85ea9bc 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -660,11 +660,9 @@ u_quad_t init_va_filerev(void); int speedup_syncer(void); int vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, size_t *buflen); -int vn_getcwd(struct thread *td, char *buf, char **retbuf, size_t *buflen); -int vn_fullpath(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf); -int vn_fullpath_global(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf); +int vn_getcwd(char *buf, char **retbuf, size_t *buflen); +int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf); +int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf); struct vnode * vn_dir_dd_ino(struct vnode *vp); int vn_commname(struct vnode *vn, char *buf, u_int buflen); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index dd8383f96250..475f5967753d 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2582,7 +2582,7 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) vref(vp); VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(curthread, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); vn_lock(vp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(vp, &va, curthread->td_ucred) == 0) { kvo->kvo_vn_fileid = va.va_fileid;