vfs_cache.c (85287) | vfs_cache.c (89306) |
---|---|
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 85287 2001-10-21 15:52:51Z des $ | 37 * $FreeBSD: head/sys/kern/vfs_cache.c 89306 2002-01-13 11:58:06Z alfred $ |
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> --- 665 unchanged lines hidden (view full) --- 711 return (EINVAL); 712 if (uap->buflen > MAXPATHLEN) 713 uap->buflen = MAXPATHLEN; 714 buf = bp = malloc(uap->buflen, M_TEMP, M_WAITOK); 715 bp += uap->buflen - 1; 716 *bp = '\0'; 717 fdp = td->td_proc->p_fd; 718 slash_prefixed = 0; | 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> --- 665 unchanged lines hidden (view full) --- 711 return (EINVAL); 712 if (uap->buflen > MAXPATHLEN) 713 uap->buflen = MAXPATHLEN; 714 buf = bp = malloc(uap->buflen, M_TEMP, M_WAITOK); 715 bp += uap->buflen - 1; 716 *bp = '\0'; 717 fdp = td->td_proc->p_fd; 718 slash_prefixed = 0; |
719 FILEDESC_LOCK(fdp); |
|
719 for (vp = fdp->fd_cdir; vp != fdp->fd_rdir && vp != rootvnode;) { 720 if (vp->v_flag & VROOT) { 721 if (vp->v_mount == NULL) { /* forced unmount */ | 720 for (vp = fdp->fd_cdir; vp != fdp->fd_rdir && vp != rootvnode;) { 721 if (vp->v_flag & VROOT) { 722 if (vp->v_mount == NULL) { /* forced unmount */ |
723 FILEDESC_UNLOCK(fdp); |
|
722 free(buf, M_TEMP); 723 return (EBADF); 724 } 725 vp = vp->v_mount->mnt_vnodecovered; 726 continue; 727 } 728 if (vp->v_dd->v_id != vp->v_ddid) { | 724 free(buf, M_TEMP); 725 return (EBADF); 726 } 727 vp = vp->v_mount->mnt_vnodecovered; 728 continue; 729 } 730 if (vp->v_dd->v_id != vp->v_ddid) { |
731 FILEDESC_UNLOCK(fdp); |
|
729 numcwdfail1++; 730 free(buf, M_TEMP); 731 return (ENOTDIR); 732 } 733 ncp = TAILQ_FIRST(&vp->v_cache_dst); 734 if (!ncp) { | 732 numcwdfail1++; 733 free(buf, M_TEMP); 734 return (ENOTDIR); 735 } 736 ncp = TAILQ_FIRST(&vp->v_cache_dst); 737 if (!ncp) { |
738 FILEDESC_UNLOCK(fdp); |
|
735 numcwdfail2++; 736 free(buf, M_TEMP); 737 return (ENOENT); 738 } 739 if (ncp->nc_dvp != vp->v_dd) { | 739 numcwdfail2++; 740 free(buf, M_TEMP); 741 return (ENOENT); 742 } 743 if (ncp->nc_dvp != vp->v_dd) { |
744 FILEDESC_UNLOCK(fdp); |
|
740 numcwdfail3++; 741 free(buf, M_TEMP); 742 return (EBADF); 743 } 744 for (i = ncp->nc_nlen - 1; i >= 0; i--) { 745 if (bp == buf) { | 745 numcwdfail3++; 746 free(buf, M_TEMP); 747 return (EBADF); 748 } 749 for (i = ncp->nc_nlen - 1; i >= 0; i--) { 750 if (bp == buf) { |
751 FILEDESC_UNLOCK(fdp); |
|
746 numcwdfail4++; 747 free(buf, M_TEMP); 748 return (ENOMEM); 749 } 750 *--bp = ncp->nc_name[i]; 751 } 752 if (bp == buf) { | 752 numcwdfail4++; 753 free(buf, M_TEMP); 754 return (ENOMEM); 755 } 756 *--bp = ncp->nc_name[i]; 757 } 758 if (bp == buf) { |
759 FILEDESC_UNLOCK(fdp); |
|
753 numcwdfail4++; 754 free(buf, M_TEMP); 755 return (ENOMEM); 756 } 757 *--bp = '/'; 758 slash_prefixed = 1; 759 vp = vp->v_dd; 760 } | 760 numcwdfail4++; 761 free(buf, M_TEMP); 762 return (ENOMEM); 763 } 764 *--bp = '/'; 765 slash_prefixed = 1; 766 vp = vp->v_dd; 767 } |
768 FILEDESC_UNLOCK(fdp); |
|
761 if (!slash_prefixed) { 762 if (bp == buf) { 763 numcwdfail4++; 764 free(buf, M_TEMP); 765 return (ENOMEM); 766 } 767 *--bp = '/'; 768 } --- 37 unchanged lines hidden (view full) --- 806 return (ENODEV); 807 if (vn == NULL) 808 return (EINVAL); 809 buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); 810 bp = buf + MAXPATHLEN - 1; 811 *bp = '\0'; 812 fdp = td->td_proc->p_fd; 813 slash_prefixed = 0; | 769 if (!slash_prefixed) { 770 if (bp == buf) { 771 numcwdfail4++; 772 free(buf, M_TEMP); 773 return (ENOMEM); 774 } 775 *--bp = '/'; 776 } --- 37 unchanged lines hidden (view full) --- 814 return (ENODEV); 815 if (vn == NULL) 816 return (EINVAL); 817 buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); 818 bp = buf + MAXPATHLEN - 1; 819 *bp = '\0'; 820 fdp = td->td_proc->p_fd; 821 slash_prefixed = 0; |
822 FILEDESC_LOCK(fdp); |
|
814 for (vp = vn; vp != fdp->fd_rdir && vp != rootvnode;) { 815 if (vp->v_flag & VROOT) { 816 if (vp->v_mount == NULL) { /* forced unmount */ | 823 for (vp = vn; vp != fdp->fd_rdir && vp != rootvnode;) { 824 if (vp->v_flag & VROOT) { 825 if (vp->v_mount == NULL) { /* forced unmount */ |
826 FILEDESC_UNLOCK(fdp); |
|
817 free(buf, M_TEMP); 818 return (EBADF); 819 } 820 vp = vp->v_mount->mnt_vnodecovered; 821 continue; 822 } 823 if (vp != vn && vp->v_dd->v_id != vp->v_ddid) { | 827 free(buf, M_TEMP); 828 return (EBADF); 829 } 830 vp = vp->v_mount->mnt_vnodecovered; 831 continue; 832 } 833 if (vp != vn && vp->v_dd->v_id != vp->v_ddid) { |
834 FILEDESC_UNLOCK(fdp); |
|
824 numfullpathfail1++; 825 free(buf, M_TEMP); 826 return (ENOTDIR); 827 } 828 ncp = TAILQ_FIRST(&vp->v_cache_dst); 829 if (!ncp) { | 835 numfullpathfail1++; 836 free(buf, M_TEMP); 837 return (ENOTDIR); 838 } 839 ncp = TAILQ_FIRST(&vp->v_cache_dst); 840 if (!ncp) { |
841 FILEDESC_UNLOCK(fdp); |
|
830 numfullpathfail2++; 831 free(buf, M_TEMP); 832 return (ENOENT); 833 } 834 if (vp != vn && ncp->nc_dvp != vp->v_dd) { | 842 numfullpathfail2++; 843 free(buf, M_TEMP); 844 return (ENOENT); 845 } 846 if (vp != vn && ncp->nc_dvp != vp->v_dd) { |
847 FILEDESC_UNLOCK(fdp); |
|
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) { | 848 numfullpathfail3++; 849 free(buf, M_TEMP); 850 return (EBADF); 851 } 852 for (i = ncp->nc_nlen - 1; i >= 0; i--) { 853 if (bp == buf) { |
854 FILEDESC_UNLOCK(fdp); |
|
841 numfullpathfail4++; 842 free(buf, M_TEMP); 843 return (ENOMEM); 844 } 845 *--bp = ncp->nc_name[i]; 846 } 847 if (bp == buf) { | 855 numfullpathfail4++; 856 free(buf, M_TEMP); 857 return (ENOMEM); 858 } 859 *--bp = ncp->nc_name[i]; 860 } 861 if (bp == buf) { |
862 FILEDESC_UNLOCK(fdp); |
|
848 numfullpathfail4++; 849 free(buf, M_TEMP); 850 return (ENOMEM); 851 } 852 *--bp = '/'; 853 slash_prefixed = 1; 854 vp = ncp->nc_dvp; 855 } 856 if (!slash_prefixed) { 857 if (bp == buf) { | 863 numfullpathfail4++; 864 free(buf, M_TEMP); 865 return (ENOMEM); 866 } 867 *--bp = '/'; 868 slash_prefixed = 1; 869 vp = ncp->nc_dvp; 870 } 871 if (!slash_prefixed) { 872 if (bp == buf) { |
873 FILEDESC_UNLOCK(fdp); |
|
858 numfullpathfail4++; 859 free(buf, M_TEMP); 860 return (ENOMEM); 861 } 862 *--bp = '/'; 863 } | 874 numfullpathfail4++; 875 free(buf, M_TEMP); 876 return (ENOMEM); 877 } 878 *--bp = '/'; 879 } |
880 FILEDESC_UNLOCK(fdp); |
|
864 numfullpathfound++; 865 *retbuf = bp; 866 *freebuf = buf; 867 return (0); 868} | 881 numfullpathfound++; 882 *retbuf = bp; 883 *freebuf = buf; 884 return (0); 885} |