Martin Natano wrote: > Below the uiomove() conversion for msdosfs. This diff prevents > truncation of uio_resid in both msdosfs_read() and msdosfs_write().
Yes. That's similar to the cd9660 diff. > Index: msdosfs/msdosfs_vnops.c > =================================================================== > RCS file: /cvs/src/sys/msdosfs/msdosfs_vnops.c,v > retrieving revision 1.105 > diff -u -p -u -r1.105 msdosfs_vnops.c > --- msdosfs/msdosfs_vnops.c 13 Jan 2016 10:00:55 -0000 1.105 > +++ msdosfs/msdosfs_vnops.c 21 Jan 2016 15:52:04 -0000 > @@ -516,10 +516,9 @@ msdosfs_read(void *v) > struct msdosfsmount *pmp = dep->de_pmp; > struct uio *uio = ap->a_uio; > int isadir, error = 0; > - uint32_t n, diff, size; > + uint32_t n, diff, size, on; > struct buf *bp; > daddr_t cn; > - long on; > > /* > * If they didn't ask for any data, then we are done. > @@ -537,7 +536,7 @@ msdosfs_read(void *v) > cn = de_cluster(pmp, uio->uio_offset); > size = pmp->pm_bpcluster; > on = uio->uio_offset & pmp->pm_crbomask; > - n = min((uint32_t) (pmp->pm_bpcluster - on), uio->uio_resid); > + n = ulmin(pmp->pm_bpcluster - on, uio->uio_resid); > > /* > * de_FileSize is uint32_t, and we know that uio_offset < > @@ -569,7 +568,7 @@ msdosfs_read(void *v) > brelse(bp); > return (error); > } > - error = uiomovei(bp->b_data + on, (int) n, uio); > + error = uiomove(bp->b_data + on, n, uio); > brelse(bp); > } while (error == 0 && uio->uio_resid > 0 && n != 0); > if (!isadir && !(vp->v_mount->mnt_flag & MNT_NOATIME)) > @@ -584,9 +583,8 @@ int > msdosfs_write(void *v) > { > struct vop_write_args *ap = v; > - int n; > - int croffset; > - int resid; > + uint32_t n, croffset; > + size_t resid; > ssize_t overrun; > int extended = 0; > uint32_t osize; > @@ -715,7 +713,7 @@ msdosfs_write(void *v) > } > } > > - n = min(uio->uio_resid, pmp->pm_bpcluster - croffset); > + n = ulmin(uio->uio_resid, pmp->pm_bpcluster - croffset); > if (uio->uio_offset + n > dep->de_FileSize) { > dep->de_FileSize = uio->uio_offset + n; > uvm_vnp_setsize(vp, dep->de_FileSize); > @@ -729,7 +727,7 @@ msdosfs_write(void *v) > /* > * Copy the data from user space into the buf header. > */ > - error = uiomovei(bp->b_data + croffset, n, uio); > + error = uiomove(bp->b_data + croffset, n, uio); > > /* > * If they want this synchronous then write it and wait for > @@ -1554,7 +1552,7 @@ msdosfs_readdir(void *v) > sizeof(struct direntry); > if (uio->uio_resid < dirbuf.d_reclen) > goto out; > - error = uiomovei(&dirbuf, dirbuf.d_reclen, uio); > + error = uiomove(&dirbuf, dirbuf.d_reclen, uio); > if (error) > goto out; > offset = dirbuf.d_off; > @@ -1682,7 +1680,7 @@ msdosfs_readdir(void *v) > goto out; > } > wlast = -1; > - error = uiomovei(&dirbuf, dirbuf.d_reclen, uio); > + error = uiomove(&dirbuf, dirbuf.d_reclen, uio); > if (error) { > brelse(bp); > goto out; > > cheers, > natano >