nfs_srvsubs.c (111119) | nfs_srvsubs.c (115301) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 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 * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 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 * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95 |
37 * $FreeBSD: head/sys/nfsserver/nfs_srvsubs.c 111119 2003-02-19 05:47:46Z imp $ | 37 * $FreeBSD: head/sys/nfsserver/nfs_srvsubs.c 115301 2003-05-25 06:17:33Z truckman $ |
38 */ 39 40#include <sys/cdefs.h> | 38 */ 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/sys/nfsserver/nfs_srvsubs.c 111119 2003-02-19 05:47:46Z imp $"); | 41__FBSDID("$FreeBSD: head/sys/nfsserver/nfs_srvsubs.c 115301 2003-05-25 06:17:33Z truckman $"); |
42 43/* 44 * These functions support the macros and help fiddle mbuf chains for 45 * the nfs op functions. They do things like create the rpc header and 46 * copy data between mbuf chains and uio lists. 47 */ 48 49#include "opt_inet6.h" --- 537 unchanged lines hidden (view full) --- 587 * error occurs but the parent was not requested. 588 * 589 * dirp may be set whether an error is returned or not, and must be 590 * released by the caller. 591 */ 592int 593nfs_namei(struct nameidata *ndp, fhandle_t *fhp, int len, 594 struct nfssvc_sock *slp, struct sockaddr *nam, struct mbuf **mdp, | 42 43/* 44 * These functions support the macros and help fiddle mbuf chains for 45 * the nfs op functions. They do things like create the rpc header and 46 * copy data between mbuf chains and uio lists. 47 */ 48 49#include "opt_inet6.h" --- 537 unchanged lines hidden (view full) --- 587 * error occurs but the parent was not requested. 588 * 589 * dirp may be set whether an error is returned or not, and must be 590 * released by the caller. 591 */ 592int 593nfs_namei(struct nameidata *ndp, fhandle_t *fhp, int len, 594 struct nfssvc_sock *slp, struct sockaddr *nam, struct mbuf **mdp, |
595 caddr_t *dposp, struct vnode **retdirp, struct thread *td, int pubflag) | 595 caddr_t *dposp, struct vnode **retdirp, int v3, struct vattr *retdirattrp, 596 int *retdirattr_retp, struct thread *td, int pubflag) |
596{ 597 int i, rem; 598 struct mbuf *md; 599 char *fromcp, *tocp, *cp; 600 struct iovec aiov; 601 struct uio auio; 602 struct vnode *dp; 603 int error, rdonly, linklen; 604 struct componentname *cnp = &ndp->ni_cnd; | 597{ 598 int i, rem; 599 struct mbuf *md; 600 char *fromcp, *tocp, *cp; 601 struct iovec aiov; 602 struct uio auio; 603 struct vnode *dp; 604 int error, rdonly, linklen; 605 struct componentname *cnp = &ndp->ni_cnd; |
606 int lockleaf = (cnp->cn_flags & LOCKLEAF) != 0; |
|
605 606 *retdirp = NULL; 607 cnp->cn_flags |= NOMACCHECK; 608 cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); 609 610 /* 611 * Copy the name from the mbuf list to ndp->ni_pnbuf 612 * and set the various ndp fields appropriately. --- 46 unchanged lines hidden (view full) --- 659 if (rdonly) 660 cnp->cn_flags |= RDONLY; 661 662 /* 663 * Set return directory. Reference to dp is implicitly transfered 664 * to the returned pointer 665 */ 666 *retdirp = dp; | 607 608 *retdirp = NULL; 609 cnp->cn_flags |= NOMACCHECK; 610 cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); 611 612 /* 613 * Copy the name from the mbuf list to ndp->ni_pnbuf 614 * and set the various ndp fields appropriately. --- 46 unchanged lines hidden (view full) --- 661 if (rdonly) 662 cnp->cn_flags |= RDONLY; 663 664 /* 665 * Set return directory. Reference to dp is implicitly transfered 666 * to the returned pointer 667 */ 668 *retdirp = dp; |
669 if (v3) { 670 vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, td); 671 *retdirattr_retp = VOP_GETATTR(dp, retdirattrp, 672 ndp->ni_cnd.cn_cred, td); 673 VOP_UNLOCK(dp, 0, td); 674 } |
|
667 668 if (pubflag) { 669 /* 670 * Oh joy. For WebNFS, handle those pesky '%' escapes, 671 * and the 'native path' indicator. 672 */ 673 cp = uma_zalloc(namei_zone, M_WAITOK); 674 fromcp = cnp->cn_pnbuf; --- 56 unchanged lines hidden (view full) --- 731 * Initialize for scan, set ni_startdir and bump ref on dp again 732 * becuase lookup() will dereference ni_startdir. 733 */ 734 735 cnp->cn_thread = td; 736 VREF(dp); 737 ndp->ni_startdir = dp; 738 | 675 676 if (pubflag) { 677 /* 678 * Oh joy. For WebNFS, handle those pesky '%' escapes, 679 * and the 'native path' indicator. 680 */ 681 cp = uma_zalloc(namei_zone, M_WAITOK); 682 fromcp = cnp->cn_pnbuf; --- 56 unchanged lines hidden (view full) --- 739 * Initialize for scan, set ni_startdir and bump ref on dp again 740 * becuase lookup() will dereference ni_startdir. 741 */ 742 743 cnp->cn_thread = td; 744 VREF(dp); 745 ndp->ni_startdir = dp; 746 |
747 if (!lockleaf) 748 cnp->cn_flags |= LOCKLEAF; |
|
739 for (;;) { 740 cnp->cn_nameptr = cnp->cn_pnbuf; 741 /* 742 * Call lookup() to do the real work. If an error occurs, 743 * ndp->ni_vp and ni_dvp are left uninitialized or NULL and 744 * we do not have to dereference anything before returning. 745 * In either case ni_startdir will be dereferenced and NULLed 746 * out. --- 9 unchanged lines hidden (view full) --- 756 * not zfree it again when we break. 757 */ 758 if ((cnp->cn_flags & ISSYMLINK) == 0) { 759 nfsrv_object_create(ndp->ni_vp); 760 if (cnp->cn_flags & (SAVENAME | SAVESTART)) 761 cnp->cn_flags |= HASBUF; 762 else 763 uma_zfree(namei_zone, cnp->cn_pnbuf); | 749 for (;;) { 750 cnp->cn_nameptr = cnp->cn_pnbuf; 751 /* 752 * Call lookup() to do the real work. If an error occurs, 753 * ndp->ni_vp and ni_dvp are left uninitialized or NULL and 754 * we do not have to dereference anything before returning. 755 * In either case ni_startdir will be dereferenced and NULLed 756 * out. --- 9 unchanged lines hidden (view full) --- 766 * not zfree it again when we break. 767 */ 768 if ((cnp->cn_flags & ISSYMLINK) == 0) { 769 nfsrv_object_create(ndp->ni_vp); 770 if (cnp->cn_flags & (SAVENAME | SAVESTART)) 771 cnp->cn_flags |= HASBUF; 772 else 773 uma_zfree(namei_zone, cnp->cn_pnbuf); |
774 if (ndp->ni_vp && !lockleaf) 775 VOP_UNLOCK(ndp->ni_vp, 0, td); |
|
764 break; 765 } 766 767 /* 768 * Validate symlink 769 */ 770 if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) 771 VOP_UNLOCK(ndp->ni_dvp, 0, td); --- 63 unchanged lines hidden (view full) --- 835 if (cnp->cn_pnbuf[0] == '/') { 836 vrele(ndp->ni_dvp); 837 ndp->ni_dvp = ndp->ni_rootdir; 838 VREF(ndp->ni_dvp); 839 } 840 ndp->ni_startdir = ndp->ni_dvp; 841 ndp->ni_dvp = NULL; 842 } | 776 break; 777 } 778 779 /* 780 * Validate symlink 781 */ 782 if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) 783 VOP_UNLOCK(ndp->ni_dvp, 0, td); --- 63 unchanged lines hidden (view full) --- 847 if (cnp->cn_pnbuf[0] == '/') { 848 vrele(ndp->ni_dvp); 849 ndp->ni_dvp = ndp->ni_rootdir; 850 VREF(ndp->ni_dvp); 851 } 852 ndp->ni_startdir = ndp->ni_dvp; 853 ndp->ni_dvp = NULL; 854 } |
855 if (!lockleaf) 856 cnp->cn_flags &= ~LOCKLEAF; |
|
843 844 /* 845 * nfs_namei() guarentees that fields will not contain garbage 846 * whether an error occurs or not. This allows the caller to track 847 * cleanup state trivially. 848 */ 849out: 850 if (error) { --- 549 unchanged lines hidden --- | 857 858 /* 859 * nfs_namei() guarentees that fields will not contain garbage 860 * whether an error occurs or not. This allows the caller to track 861 * cleanup state trivially. 862 */ 863out: 864 if (error) { --- 549 unchanged lines hidden --- |