Deleted Added
full compact
vfs_cache.c (84249) vfs_cache.c (85287)
1/*
2 * Copyright (c) 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Poul-Henning Kamp of the FreeBSD Project.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95
1/*
2 * Copyright (c) 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Poul-Henning Kamp of the FreeBSD Project.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95
37 * $FreeBSD: head/sys/kern/vfs_cache.c 84249 2001-10-01 04:33:35Z dillon $
37 * $FreeBSD: head/sys/kern/vfs_cache.c 85287 2001-10-21 15:52:51Z des $
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/lock.h>
44#include <sys/sysctl.h>
45#include <sys/mount.h>

--- 742 unchanged lines hidden (view full) ---

788STATNODE(numfullpathcalls);
789STATNODE(numfullpathfail1);
790STATNODE(numfullpathfail2);
791STATNODE(numfullpathfail3);
792STATNODE(numfullpathfail4);
793STATNODE(numfullpathfound);
794
795int
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/lock.h>
44#include <sys/sysctl.h>
45#include <sys/mount.h>

--- 742 unchanged lines hidden (view full) ---

788STATNODE(numfullpathcalls);
789STATNODE(numfullpathfail1);
790STATNODE(numfullpathfail2);
791STATNODE(numfullpathfail3);
792STATNODE(numfullpathfail4);
793STATNODE(numfullpathfound);
794
795int
796textvp_fullpath(struct proc *p, char **retbuf, char **retfreebuf) {
796vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf)
797{
797 char *bp, *buf;
798 int i, slash_prefixed;
799 struct filedesc *fdp;
800 struct namecache *ncp;
798 char *bp, *buf;
799 int i, slash_prefixed;
800 struct filedesc *fdp;
801 struct namecache *ncp;
801 struct vnode *vp, *textvp;
802 struct vnode *vp;
802
803 numfullpathcalls++;
804 if (disablefullpath)
805 return (ENODEV);
803
804 numfullpathcalls++;
805 if (disablefullpath)
806 return (ENODEV);
806 textvp = p->p_textvp;
807 if (textvp == NULL)
807 if (vn == NULL)
808 return (EINVAL);
809 buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
810 bp = buf + MAXPATHLEN - 1;
811 *bp = '\0';
808 return (EINVAL);
809 buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
810 bp = buf + MAXPATHLEN - 1;
811 *bp = '\0';
812 fdp = p->p_fd;
812 fdp = td->td_proc->p_fd;
813 slash_prefixed = 0;
813 slash_prefixed = 0;
814 for (vp = textvp; vp != fdp->fd_rdir && vp != rootvnode;) {
814 for (vp = vn; vp != fdp->fd_rdir && vp != rootvnode;) {
815 if (vp->v_flag & VROOT) {
816 if (vp->v_mount == NULL) { /* forced unmount */
817 free(buf, M_TEMP);
818 return (EBADF);
819 }
820 vp = vp->v_mount->mnt_vnodecovered;
821 continue;
822 }
815 if (vp->v_flag & VROOT) {
816 if (vp->v_mount == NULL) { /* forced unmount */
817 free(buf, M_TEMP);
818 return (EBADF);
819 }
820 vp = vp->v_mount->mnt_vnodecovered;
821 continue;
822 }
823 if (vp != textvp && vp->v_dd->v_id != vp->v_ddid) {
823 if (vp != vn && vp->v_dd->v_id != vp->v_ddid) {
824 numfullpathfail1++;
825 free(buf, M_TEMP);
826 return (ENOTDIR);
827 }
828 ncp = TAILQ_FIRST(&vp->v_cache_dst);
829 if (!ncp) {
830 numfullpathfail2++;
831 free(buf, M_TEMP);
832 return (ENOENT);
833 }
824 numfullpathfail1++;
825 free(buf, M_TEMP);
826 return (ENOTDIR);
827 }
828 ncp = TAILQ_FIRST(&vp->v_cache_dst);
829 if (!ncp) {
830 numfullpathfail2++;
831 free(buf, M_TEMP);
832 return (ENOENT);
833 }
834 if (vp != textvp && ncp->nc_dvp != vp->v_dd) {
834 if (vp != vn && ncp->nc_dvp != vp->v_dd) {
835 numfullpathfail3++;
836 free(buf, M_TEMP);
837 return (EBADF);
838 }
839 for (i = ncp->nc_nlen - 1; i >= 0; i--) {
840 if (bp == buf) {
841 numfullpathfail4++;
842 free(buf, M_TEMP);

--- 15 unchanged lines hidden (view full) ---

858 numfullpathfail4++;
859 free(buf, M_TEMP);
860 return (ENOMEM);
861 }
862 *--bp = '/';
863 }
864 numfullpathfound++;
865 *retbuf = bp;
835 numfullpathfail3++;
836 free(buf, M_TEMP);
837 return (EBADF);
838 }
839 for (i = ncp->nc_nlen - 1; i >= 0; i--) {
840 if (bp == buf) {
841 numfullpathfail4++;
842 free(buf, M_TEMP);

--- 15 unchanged lines hidden (view full) ---

858 numfullpathfail4++;
859 free(buf, M_TEMP);
860 return (ENOMEM);
861 }
862 *--bp = '/';
863 }
864 numfullpathfound++;
865 *retbuf = bp;
866 *retfreebuf = buf;
866 *freebuf = buf;
867 return (0);
868}
867 return (0);
868}