diff options
author | green <green@FreeBSD.org> | 2000-04-26 11:57:45 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 2000-04-26 11:57:45 +0000 |
commit | 6bad412525aca72f3c4b4d706db249c402952055 (patch) | |
tree | cc8b18ca8a121d2db24fa3bdfc4f4d04970aaba6 /sys/miscfs/procfs/procfs_subr.c | |
parent | 9bef7c0136ba2ed59a50715ad48c304dc5ebdfb1 (diff) | |
download | FreeBSD-src-6bad412525aca72f3c4b4d706db249c402952055.zip FreeBSD-src-6bad412525aca72f3c4b4d706db249c402952055.tar.gz |
Move procfs_fullpath() to vfs_cache.c, with a rename to textvp_fullpath().
There's no excuse to have code in synthetic filestores that allows direct
references to the textvp anymore.
Feature requested by: msmith
Feature agreed to by: warner
Move requested by: phk
Move agreed to by: bde
Diffstat (limited to 'sys/miscfs/procfs/procfs_subr.c')
-rw-r--r-- | sys/miscfs/procfs/procfs_subr.c | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c index 053a620..c86c6c8 100644 --- a/sys/miscfs/procfs/procfs_subr.c +++ b/sys/miscfs/procfs/procfs_subr.c @@ -410,99 +410,3 @@ procfs_exit(struct proc *p) pfs = pfs->pfs_next; } } - -/* - * Thus begins the fullpath magic. - */ - -SYSCTL_DECL(_vfs_cache); - -#define STATNODE(name) \ - static u_int name; \ - SYSCTL_INT(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, "") - -static int disablefullpath; -SYSCTL_INT(_debug, OID_AUTO, disablefullpath, CTLFLAG_RW, - &disablefullpath, 0, ""); - -STATNODE(numfullpathcalls); -STATNODE(numfullpathfail1); -STATNODE(numfullpathfail2); -STATNODE(numfullpathfail3); -STATNODE(numfullpathfail4); -STATNODE(numfullpathfound); - -int -procfs_fullpath(struct proc *p, char **retbuf, char **retfreebuf) { - char *bp, *buf; - int i, slash_prefixed; - struct filedesc *fdp; - struct namecache *ncp; - struct vnode *vp, *textvp; - - numfullpathcalls++; - if (disablefullpath) - return (ENODEV); - textvp = p->p_textvp; - if (textvp == NULL) - return (EINVAL); - buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); - bp = buf + MAXPATHLEN - 1; - *bp = '\0'; - fdp = p->p_fd; - slash_prefixed = 0; - for (vp = textvp; vp != fdp->fd_rdir && vp != rootvnode;) { - if (vp->v_flag & VROOT) { - if (vp->v_mount == NULL) { /* forced unmount */ - free(buf, M_TEMP); - return (EBADF); - } - vp = vp->v_mount->mnt_vnodecovered; - continue; - } - if (vp != textvp && vp->v_dd->v_id != vp->v_ddid) { - numfullpathfail1++; - free(buf, M_TEMP); - return (ENOTDIR); - } - ncp = TAILQ_FIRST(&vp->v_cache_dst); - if (!ncp) { - numfullpathfail2++; - free(buf, M_TEMP); - return (ENOENT); - } - if (vp != textvp && ncp->nc_dvp != vp->v_dd) { - numfullpathfail3++; - free(buf, M_TEMP); - return (EBADF); - } - for (i = ncp->nc_nlen - 1; i >= 0; i--) { - if (bp == buf) { - numfullpathfail4++; - free(buf, M_TEMP); - return (ENOMEM); - } - *--bp = ncp->nc_name[i]; - } - if (bp == buf) { - numfullpathfail4++; - free(buf, M_TEMP); - return (ENOMEM); - } - *--bp = '/'; - slash_prefixed = 1; - vp = ncp->nc_dvp; - } - if (!slash_prefixed) { - if (bp == buf) { - numfullpathfail4++; - free(buf, M_TEMP); - return (ENOMEM); - } - *--bp = '/'; - } - numfullpathfound++; - *retbuf = bp; - *retfreebuf = buf; - return (0); -} |