nfs_common.c (29288) | nfs_common.c (29653) |
---|---|
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.3 (Berkeley) 1/4/94 | 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.3 (Berkeley) 1/4/94 |
37 * $Id: nfs_subs.c,v 1.41 1997/08/16 19:15:59 wollman Exp $ | 37 * $Id: nfs_subs.c,v 1.42 1997/09/10 19:52:26 phk Exp $ |
38 */ 39 40/* 41 * These functions support the macros and help fiddle mbuf chains for 42 * the nfs op functions. They do things like create the rpc header and 43 * copy data between mbuf chains and uio lists. 44 */ 45#include <sys/param.h> --- 1393 unchanged lines hidden (view full) --- 1439 register char *fromcp, *tocp, *cp; 1440 struct iovec aiov; 1441 struct uio auio; 1442 struct vnode *dp; 1443 int error, rdonly, linklen; 1444 struct componentname *cnp = &ndp->ni_cnd; 1445 1446 *retdirp = (struct vnode *)0; | 38 */ 39 40/* 41 * These functions support the macros and help fiddle mbuf chains for 42 * the nfs op functions. They do things like create the rpc header and 43 * copy data between mbuf chains and uio lists. 44 */ 45#include <sys/param.h> --- 1393 unchanged lines hidden (view full) --- 1439 register char *fromcp, *tocp, *cp; 1440 struct iovec aiov; 1441 struct uio auio; 1442 struct vnode *dp; 1443 int error, rdonly, linklen; 1444 struct componentname *cnp = &ndp->ni_cnd; 1445 1446 *retdirp = (struct vnode *)0; |
1447 MALLOC(cnp->cn_pnbuf, char *, len + 1, M_NAMEI, M_WAITOK); | 1447 cnp->cn_pnbuf = zalloc(namei_zone); 1448 |
1448 /* 1449 * Copy the name from the mbuf list to ndp->ni_pnbuf 1450 * and set the various ndp fields appropriately. 1451 */ 1452 fromcp = *dposp; 1453 tocp = cnp->cn_pnbuf; 1454 md = *mdp; 1455 rem = mtod(md, caddr_t) + md->m_len - fromcp; --- 45 unchanged lines hidden (view full) --- 1501 1502 *retdirp = dp; 1503 1504 if (pubflag) { 1505 /* 1506 * Oh joy. For WebNFS, handle those pesky '%' escapes, 1507 * and the 'native path' indicator. 1508 */ | 1449 /* 1450 * Copy the name from the mbuf list to ndp->ni_pnbuf 1451 * and set the various ndp fields appropriately. 1452 */ 1453 fromcp = *dposp; 1454 tocp = cnp->cn_pnbuf; 1455 md = *mdp; 1456 rem = mtod(md, caddr_t) + md->m_len - fromcp; --- 45 unchanged lines hidden (view full) --- 1502 1503 *retdirp = dp; 1504 1505 if (pubflag) { 1506 /* 1507 * Oh joy. For WebNFS, handle those pesky '%' escapes, 1508 * and the 'native path' indicator. 1509 */ |
1509 MALLOC(cp, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); | 1510 cp = zalloc(namei_zone); |
1510 fromcp = cnp->cn_pnbuf; 1511 tocp = cp; 1512 if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) { 1513 switch ((unsigned char)*fromcp) { 1514 case WEBNFS_NATIVE_CHAR: 1515 /* 1516 * 'Native' path for us is the same 1517 * as a path according to the NFS spec, 1518 * just skip the escape char. 1519 */ 1520 fromcp++; 1521 break; 1522 /* 1523 * More may be added in the future, range 0x80-0xff 1524 */ 1525 default: 1526 error = EIO; | 1511 fromcp = cnp->cn_pnbuf; 1512 tocp = cp; 1513 if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) { 1514 switch ((unsigned char)*fromcp) { 1515 case WEBNFS_NATIVE_CHAR: 1516 /* 1517 * 'Native' path for us is the same 1518 * as a path according to the NFS spec, 1519 * just skip the escape char. 1520 */ 1521 fromcp++; 1522 break; 1523 /* 1524 * More may be added in the future, range 0x80-0xff 1525 */ 1526 default: 1527 error = EIO; |
1527 FREE(cp, M_NAMEI); | 1528 zfree(namei_zone, cp); |
1528 goto out; 1529 } 1530 } 1531 /* 1532 * Translate the '%' escapes, URL-style. 1533 */ 1534 while (*fromcp != '\0') { 1535 if (*fromcp == WEBNFS_ESC_CHAR) { 1536 if (fromcp[1] != '\0' && fromcp[2] != '\0') { 1537 fromcp++; 1538 *tocp++ = HEXSTRTOI(fromcp); 1539 fromcp += 2; 1540 continue; 1541 } else { 1542 error = ENOENT; | 1529 goto out; 1530 } 1531 } 1532 /* 1533 * Translate the '%' escapes, URL-style. 1534 */ 1535 while (*fromcp != '\0') { 1536 if (*fromcp == WEBNFS_ESC_CHAR) { 1537 if (fromcp[1] != '\0' && fromcp[2] != '\0') { 1538 fromcp++; 1539 *tocp++ = HEXSTRTOI(fromcp); 1540 fromcp += 2; 1541 continue; 1542 } else { 1543 error = ENOENT; |
1543 FREE(cp, M_NAMEI); | 1544 zfree(namei_zone, cp); |
1544 goto out; 1545 } 1546 } else 1547 *tocp++ = *fromcp++; 1548 } 1549 *tocp = '\0'; | 1545 goto out; 1546 } 1547 } else 1548 *tocp++ = *fromcp++; 1549 } 1550 *tocp = '\0'; |
1550 FREE(cnp->cn_pnbuf, M_NAMEI); | 1551 zfree(namei_zone, cnp->cn_pnbuf); |
1551 cnp->cn_pnbuf = cp; 1552 } 1553 1554 ndp->ni_pathlen = (tocp - cnp->cn_pnbuf) + 1; 1555 ndp->ni_segflg = UIO_SYSSPACE; 1556 1557 if (pubflag) { 1558 ndp->ni_rootdir = rootvnode; --- 37 unchanged lines hidden (view full) --- 1596 break; 1597 } 1598 1599 if (ndp->ni_loopcnt++ >= MAXSYMLINKS) { 1600 error = ELOOP; 1601 break; 1602 } 1603 if (ndp->ni_pathlen > 1) | 1552 cnp->cn_pnbuf = cp; 1553 } 1554 1555 ndp->ni_pathlen = (tocp - cnp->cn_pnbuf) + 1; 1556 ndp->ni_segflg = UIO_SYSSPACE; 1557 1558 if (pubflag) { 1559 ndp->ni_rootdir = rootvnode; --- 37 unchanged lines hidden (view full) --- 1597 break; 1598 } 1599 1600 if (ndp->ni_loopcnt++ >= MAXSYMLINKS) { 1601 error = ELOOP; 1602 break; 1603 } 1604 if (ndp->ni_pathlen > 1) |
1604 MALLOC(cp, char *, MAXPATHLEN, M_NAMEI, M_WAITOK); | 1605 cp = zalloc(namei_zone); |
1605 else 1606 cp = cnp->cn_pnbuf; 1607 aiov.iov_base = cp; 1608 aiov.iov_len = MAXPATHLEN; 1609 auio.uio_iov = &aiov; 1610 auio.uio_iovcnt = 1; 1611 auio.uio_offset = 0; 1612 auio.uio_rw = UIO_READ; 1613 auio.uio_segflg = UIO_SYSSPACE; 1614 auio.uio_procp = (struct proc *)0; 1615 auio.uio_resid = MAXPATHLEN; 1616 error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); 1617 if (error) { 1618 badlink: 1619 if (ndp->ni_pathlen > 1) | 1606 else 1607 cp = cnp->cn_pnbuf; 1608 aiov.iov_base = cp; 1609 aiov.iov_len = MAXPATHLEN; 1610 auio.uio_iov = &aiov; 1611 auio.uio_iovcnt = 1; 1612 auio.uio_offset = 0; 1613 auio.uio_rw = UIO_READ; 1614 auio.uio_segflg = UIO_SYSSPACE; 1615 auio.uio_procp = (struct proc *)0; 1616 auio.uio_resid = MAXPATHLEN; 1617 error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); 1618 if (error) { 1619 badlink: 1620 if (ndp->ni_pathlen > 1) |
1620 FREE(cp, M_NAMEI); | 1621 zfree(namei_zone, cp); |
1621 break; 1622 } 1623 linklen = MAXPATHLEN - auio.uio_resid; 1624 if (linklen == 0) { 1625 error = ENOENT; 1626 goto badlink; 1627 } 1628 if (linklen + ndp->ni_pathlen >= MAXPATHLEN) { 1629 error = ENAMETOOLONG; 1630 goto badlink; 1631 } 1632 if (ndp->ni_pathlen > 1) { 1633 bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen); | 1622 break; 1623 } 1624 linklen = MAXPATHLEN - auio.uio_resid; 1625 if (linklen == 0) { 1626 error = ENOENT; 1627 goto badlink; 1628 } 1629 if (linklen + ndp->ni_pathlen >= MAXPATHLEN) { 1630 error = ENAMETOOLONG; 1631 goto badlink; 1632 } 1633 if (ndp->ni_pathlen > 1) { 1634 bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen); |
1634 FREE(cnp->cn_pnbuf, M_NAMEI); | 1635 zfree(namei_zone, cnp->cn_pnbuf); |
1635 cnp->cn_pnbuf = cp; 1636 } else 1637 cnp->cn_pnbuf[linklen] = '\0'; 1638 ndp->ni_pathlen += linklen; 1639 vput(ndp->ni_vp); 1640 dp = ndp->ni_dvp; 1641 /* 1642 * Check if root directory should replace current directory. 1643 */ 1644 if (cnp->cn_pnbuf[0] == '/') { 1645 vrele(dp); 1646 dp = ndp->ni_rootdir; 1647 VREF(dp); 1648 } 1649 } 1650 } 1651out: | 1636 cnp->cn_pnbuf = cp; 1637 } else 1638 cnp->cn_pnbuf[linklen] = '\0'; 1639 ndp->ni_pathlen += linklen; 1640 vput(ndp->ni_vp); 1641 dp = ndp->ni_dvp; 1642 /* 1643 * Check if root directory should replace current directory. 1644 */ 1645 if (cnp->cn_pnbuf[0] == '/') { 1646 vrele(dp); 1647 dp = ndp->ni_rootdir; 1648 VREF(dp); 1649 } 1650 } 1651 } 1652out: |
1652 FREE(cnp->cn_pnbuf, M_NAMEI); | 1653 zfree(namei_zone, cnp->cn_pnbuf); |
1653 return (error); 1654} 1655 1656/* 1657 * A fiddled version of m_adj() that ensures null fill to a long 1658 * boundary and only trims off the back end 1659 */ 1660void --- 440 unchanged lines hidden --- | 1654 return (error); 1655} 1656 1657/* 1658 * A fiddled version of m_adj() that ensures null fill to a long 1659 * boundary and only trims off the back end 1660 */ 1661void --- 440 unchanged lines hidden --- |