cache: drop the always curthread argument from reverse lookup routines
Note VOP_VPTOCNP keeps getting it as temporary compatibility for zfs. Tested by: pho
This commit is contained in:
parent
c005970d97
commit
a0d6ab1e69
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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]";
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -575,8 +575,7 @@ interpret:
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user