msdosfs_vnops.c (33791) | msdosfs_vnops.c (33848) |
---|---|
1/* $Id: msdosfs_vnops.c,v 1.60 1998/02/23 16:44:36 ache Exp $ */ | 1/* $Id: msdosfs_vnops.c,v 1.61 1998/02/24 14:13:16 ache Exp $ */ |
2/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ 3 4/*- 5 * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. 6 * Copyright (C) 1994, 1995, 1997 TooLs GmbH. 7 * All rights reserved. 8 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). 9 * --- 1524 unchanged lines hidden (view full) --- 1534 u_long **a_cookies; 1535 } */ *ap; 1536{ 1537 int error = 0; 1538 int diff; 1539 long n; 1540 int blsize; 1541 long on; | 2/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ 3 4/*- 5 * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. 6 * Copyright (C) 1994, 1995, 1997 TooLs GmbH. 7 * All rights reserved. 8 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). 9 * --- 1524 unchanged lines hidden (view full) --- 1534 u_long **a_cookies; 1535 } */ *ap; 1536{ 1537 int error = 0; 1538 int diff; 1539 long n; 1540 int blsize; 1541 long on; |
1542 long lost; 1543 long count; | |
1544 u_long cn; 1545 u_long fileno; 1546 u_long dirsperblk; 1547 long bias = 0; 1548 daddr_t bn, lbn; 1549 struct buf *bp; 1550 struct denode *dep = VTODE(ap->a_vp); 1551 struct msdosfsmount *pmp = dep->de_pmp; --- 24 unchanged lines hidden (view full) --- 1576 */ 1577 bzero(dirbuf.d_name, sizeof(dirbuf.d_name)); 1578 1579 /* 1580 * If the user buffer is smaller than the size of one dos directory 1581 * entry or the file offset is not a multiple of the size of a 1582 * directory entry, then we fail the read. 1583 */ | 1542 u_long cn; 1543 u_long fileno; 1544 u_long dirsperblk; 1545 long bias = 0; 1546 daddr_t bn, lbn; 1547 struct buf *bp; 1548 struct denode *dep = VTODE(ap->a_vp); 1549 struct msdosfsmount *pmp = dep->de_pmp; --- 24 unchanged lines hidden (view full) --- 1574 */ 1575 bzero(dirbuf.d_name, sizeof(dirbuf.d_name)); 1576 1577 /* 1578 * If the user buffer is smaller than the size of one dos directory 1579 * entry or the file offset is not a multiple of the size of a 1580 * directory entry, then we fail the read. 1581 */ |
1584 count = uio->uio_resid & ~(sizeof(struct direntry) - 1); 1585 offset = uio->uio_offset; 1586 if (count < sizeof(struct direntry) || | 1582 off = offset = uio->uio_offset; 1583 if (uio->uio_resid < sizeof(struct direntry) || |
1587 (offset & (sizeof(struct direntry) - 1))) 1588 return (EINVAL); | 1584 (offset & (sizeof(struct direntry) - 1))) 1585 return (EINVAL); |
1589 lost = uio->uio_resid - count; 1590 uio->uio_resid = count; | |
1591 1592 if (ap->a_ncookies) { 1593 ncookies = uio->uio_resid / 16; 1594 MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, 1595 M_WAITOK); 1596 *ap->a_cookies = cookies; 1597 *ap->a_ncookies = ncookies; 1598 } --- 36 unchanged lines hidden (view full) --- 1635 } 1636 dirbuf.d_reclen = GENERIC_DIRSIZ(&dirbuf); 1637 if (uio->uio_resid < dirbuf.d_reclen) 1638 goto out; 1639 error = uiomove((caddr_t) &dirbuf, 1640 dirbuf.d_reclen, uio); 1641 if (error) 1642 goto out; | 1586 1587 if (ap->a_ncookies) { 1588 ncookies = uio->uio_resid / 16; 1589 MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, 1590 M_WAITOK); 1591 *ap->a_cookies = cookies; 1592 *ap->a_ncookies = ncookies; 1593 } --- 36 unchanged lines hidden (view full) --- 1630 } 1631 dirbuf.d_reclen = GENERIC_DIRSIZ(&dirbuf); 1632 if (uio->uio_resid < dirbuf.d_reclen) 1633 goto out; 1634 error = uiomove((caddr_t) &dirbuf, 1635 dirbuf.d_reclen, uio); 1636 if (error) 1637 goto out; |
1638 offset += sizeof(struct direntry); 1639 off = offset; |
|
1643 if (cookies) { 1644 *cookies++ = offset; 1645 if (--ncookies <= 0) 1646 goto out; 1647 } | 1640 if (cookies) { 1641 *cookies++ = offset; 1642 if (--ncookies <= 0) 1643 goto out; 1644 } |
1648 offset += sizeof(struct direntry); | |
1649 } 1650 } 1651 } 1652 1653 off = offset; 1654 while (uio->uio_resid > 0) { 1655 lbn = de_cluster(pmp, offset - bias); 1656 on = (offset - bias) & pmp->pm_crbomask; --- 101 unchanged lines hidden (view full) --- 1758 } 1759 error = uiomove((caddr_t) &dirbuf, 1760 dirbuf.d_reclen, uio); 1761 if (error) { 1762 brelse(bp); 1763 goto out; 1764 } 1765 if (cookies) { | 1645 } 1646 } 1647 } 1648 1649 off = offset; 1650 while (uio->uio_resid > 0) { 1651 lbn = de_cluster(pmp, offset - bias); 1652 on = (offset - bias) & pmp->pm_crbomask; --- 101 unchanged lines hidden (view full) --- 1754 } 1755 error = uiomove((caddr_t) &dirbuf, 1756 dirbuf.d_reclen, uio); 1757 if (error) { 1758 brelse(bp); 1759 goto out; 1760 } 1761 if (cookies) { |
1766 *cookies++ = off; 1767 off = offset + sizeof(struct direntry); | 1762 *cookies++ = offset + sizeof(struct direntry); |
1768 if (--ncookies <= 0) { 1769 brelse(bp); 1770 goto out; 1771 } 1772 } | 1763 if (--ncookies <= 0) { 1764 brelse(bp); 1765 goto out; 1766 } 1767 } |
1768 off = offset + sizeof(struct direntry); |
|
1773 } 1774 brelse(bp); 1775 } 1776out: 1777 /* Subtract unused cookies */ 1778 if (ap->a_ncookies) 1779 *ap->a_ncookies -= ncookies; 1780 | 1769 } 1770 brelse(bp); 1771 } 1772out: 1773 /* Subtract unused cookies */ 1774 if (ap->a_ncookies) 1775 *ap->a_ncookies -= ncookies; 1776 |
1781 uio->uio_offset = offset; 1782 uio->uio_resid += lost; | 1777 uio->uio_offset = off; |
1783 1784 /* 1785 * Set the eofflag (NFS uses it) 1786 */ 1787 if (ap->a_eofflag) 1788 if (dep->de_FileSize - (offset - bias) <= 0) 1789 *ap->a_eofflag = 1; 1790 else --- 186 unchanged lines hidden --- | 1778 1779 /* 1780 * Set the eofflag (NFS uses it) 1781 */ 1782 if (ap->a_eofflag) 1783 if (dep->de_FileSize - (offset - bias) <= 0) 1784 *ap->a_eofflag = 1; 1785 else --- 186 unchanged lines hidden --- |