union_subr.c (28189) | union_subr.c (29653) |
---|---|
1/* 2 * Copyright (c) 1994 Jan-Simon Pendry 3 * Copyright (c) 1994 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Jan-Simon Pendry. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 | 1/* 2 * Copyright (c) 1994 Jan-Simon Pendry 3 * Copyright (c) 1994 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Jan-Simon Pendry. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 |
38 * $Id: union_subr.c,v 1.19 1997/08/02 14:32:28 bde Exp $ | 38 * $Id: union_subr.c,v 1.20 1997/08/14 03:57:46 kato Exp $ |
39 */ 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/vnode.h> 44#include <sys/namei.h> 45#include <sys/malloc.h> 46#include <sys/fcntl.h> --- 688 unchanged lines hidden (view full) --- 735 * some of the work done by NDINIT, some of the work done 736 * by namei, some of the work done by lookup and some of 737 * the work done by VOP_LOOKUP when given a CREATE flag. 738 * Conclusion: Horrible. 739 * 740 * The pathname buffer will be FREEed by VOP_MKDIR. 741 */ 742 cn->cn_namelen = pathlen; | 39 */ 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/vnode.h> 44#include <sys/namei.h> 45#include <sys/malloc.h> 46#include <sys/fcntl.h> --- 688 unchanged lines hidden (view full) --- 735 * some of the work done by NDINIT, some of the work done 736 * by namei, some of the work done by lookup and some of 737 * the work done by VOP_LOOKUP when given a CREATE flag. 738 * Conclusion: Horrible. 739 * 740 * The pathname buffer will be FREEed by VOP_MKDIR. 741 */ 742 cn->cn_namelen = pathlen; |
743 cn->cn_pnbuf = malloc(cn->cn_namelen+1, M_NAMEI, M_WAITOK); | 743 cn->cn_pnbuf = zalloc(namei_zone); |
744 bcopy(path, cn->cn_pnbuf, cn->cn_namelen); 745 cn->cn_pnbuf[cn->cn_namelen] = '\0'; 746 747 cn->cn_nameiop = CREATE; 748 cn->cn_flags = (LOCKPARENT|HASBUF|SAVENAME|SAVESTART|ISLASTCN); 749 cn->cn_proc = cnp->cn_proc; 750 if (um->um_op == UNMNT_ABOVE) 751 cn->cn_cred = cnp->cn_cred; 752 else 753 cn->cn_cred = um->um_cred; 754 cn->cn_nameptr = cn->cn_pnbuf; 755 cn->cn_hash = cnp->cn_hash; 756 cn->cn_consume = cnp->cn_consume; 757 758 VREF(dvp); 759 error = relookup(dvp, vpp, cn); 760 if (!error) 761 vrele(dvp); 762 else { | 744 bcopy(path, cn->cn_pnbuf, cn->cn_namelen); 745 cn->cn_pnbuf[cn->cn_namelen] = '\0'; 746 747 cn->cn_nameiop = CREATE; 748 cn->cn_flags = (LOCKPARENT|HASBUF|SAVENAME|SAVESTART|ISLASTCN); 749 cn->cn_proc = cnp->cn_proc; 750 if (um->um_op == UNMNT_ABOVE) 751 cn->cn_cred = cnp->cn_cred; 752 else 753 cn->cn_cred = um->um_cred; 754 cn->cn_nameptr = cn->cn_pnbuf; 755 cn->cn_hash = cnp->cn_hash; 756 cn->cn_consume = cnp->cn_consume; 757 758 VREF(dvp); 759 error = relookup(dvp, vpp, cn); 760 if (!error) 761 vrele(dvp); 762 else { |
763 free(cn->cn_pnbuf, M_NAMEI); | 763 zfree(namei_zone, cn->cn_pnbuf); |
764 cn->cn_pnbuf = '\0'; 765 } 766 767 return (error); 768} 769 770/* 771 * Create a shadow directory in the upper layer. --- 129 unchanged lines hidden (view full) --- 901 * reasons outlines in union_mkshadow). 902 * The difference here is that the file is owned by 903 * the current user, rather than by the person who 904 * did the mount, since the current user needs to be 905 * able to write the file (that's why it is being 906 * copied in the first place). 907 */ 908 cn.cn_namelen = strlen(un->un_path); | 764 cn->cn_pnbuf = '\0'; 765 } 766 767 return (error); 768} 769 770/* 771 * Create a shadow directory in the upper layer. --- 129 unchanged lines hidden (view full) --- 901 * reasons outlines in union_mkshadow). 902 * The difference here is that the file is owned by 903 * the current user, rather than by the person who 904 * did the mount, since the current user needs to be 905 * able to write the file (that's why it is being 906 * copied in the first place). 907 */ 908 cn.cn_namelen = strlen(un->un_path); |
909 cn.cn_pnbuf = (caddr_t) malloc(cn.cn_namelen+1, M_NAMEI, M_WAITOK); | 909 cn.cn_pnbuf = zalloc(namei_zone); |
910 bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1); 911 cn.cn_nameiop = CREATE; 912 cn.cn_flags = (LOCKPARENT|HASBUF|SAVENAME|SAVESTART|ISLASTCN); 913 cn.cn_proc = p; 914 cn.cn_cred = p->p_ucred; 915 cn.cn_nameptr = cn.cn_pnbuf; 916 cn.cn_hash = un->un_hash; 917 cn.cn_consume = 0; --- 211 unchanged lines hidden --- | 910 bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1); 911 cn.cn_nameiop = CREATE; 912 cn.cn_flags = (LOCKPARENT|HASBUF|SAVENAME|SAVESTART|ISLASTCN); 913 cn.cn_proc = p; 914 cn.cn_cred = p->p_ucred; 915 cn.cn_nameptr = cn.cn_pnbuf; 916 cn.cn_hash = un->un_hash; 917 cn.cn_consume = 0; --- 211 unchanged lines hidden --- |