uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
uiomove((char *)bp->b_data + blkoffset, xfersize, uio);  if (error != 0) bzero((char *)bp->b_data + blkoffset, xfersize);
WRITE(v)	void *v;{	struct vop_write_args /* {		struct vnode *a_vp;		struct uio *a_uio;		int a_ioflag;		struct ucred *a_cred;	} */ *ap = v;	register struct vnode *vp;	register struct uio *uio;	register struct inode *ip;	register FS *fs;	struct buf *bp;	struct proc *p;	daddr_t lbn;	off_t osize;	int blkoffset, error, flags, ioflag, resid, size, xfersize;	struct timespec ts;	ioflag = ap->a_ioflag;	uio = ap->a_uio;	vp = ap->a_vp;	ip = VTOI(vp);#ifdef DIAGNOSTIC	if (uio->uio_rw != UIO_WRITE)		panic("%s: mode", WRITE_S);#endif	switch (vp->v_type) {	case VREG:		if (ioflag & IO_APPEND)			uio->uio_offset = ip->i_ffs_size;		if ((ip->i_ffs_flags & APPEND) && uio->uio_offset != ip->i_ffs_size)			return (EPERM);		/* FALLTHROUGH */	case VLNK:		break;	case VDIR:		if ((ioflag & IO_SYNC) == 0)			panic("%s: nonsync dir write", WRITE_S);		break;	default:		panic("%s: type", WRITE_S);	}	fs = ip->I_FS;	if (uio->uio_offset < 0 ||	    (u_int64_t)uio->uio_offset + uio->uio_resid > MAXFILESIZE)		return (EFBIG);	/*	 * Maybe this should be above the vnode op call, but so long as	 * file servers have no limits, I don't think it matters.	 */	p = uio->uio_procp;	if (vp->v_type == VREG && p &&	    uio->uio_offset + uio->uio_resid >	    p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {		psignal(p, SIGXFSZ);		return (EFBIG);	}	resid = uio->uio_resid;	osize = ip->i_ffs_size;	flags = ioflag & IO_SYNC ? B_SYNC : 0;	for (error = 0; uio->uio_resid > 0;) {		lbn = lblkno(fs, uio->uio_offset);		blkoffset = blkoff(fs, uio->uio_offset);		xfersize = fs->fs_bsize - blkoffset;		if (uio->uio_resid < xfersize)			xfersize = uio->uio_resid;		if (fs->fs_bsize > xfersize)			flags |= B_CLRBUF;		else			flags &= ~B_CLRBUF;		if ((error = VOP_BALLOC(vp, uio->uio_offset, xfersize,					ap->a_cred, flags, &bp)) != 0)			break;		if (uio->uio_offset + xfersize > ip->i_ffs_size) {			ip->i_ffs_size = uio->uio_offset + xfersize;			vnode_pager_setsize(vp, (u_long)ip->i_ffs_size);		}		(void)vnode_pager_uncache(vp);		size = BLKSIZE(fs, ip, lbn) - bp->b_resid;		if (size < xfersize)			xfersize = size;		error =		    uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);#ifdef LFS_READWRITE		(void)VOP_BWRITE(bp);#else		if (ioflag & IO_SYNC)			(void)bwrite(bp);		else if (xfersize + blkoffset == fs->fs_bsize) {			if (doclusterwrite)				cluster_write(bp, ip->i_ffs_size);			else				bawrite(bp);		} else			bdwrite(bp);#endif		if (error || xfersize == 0)			break;		ip->i_flag |= IN_CHANGE | IN_UPDATE;	}	/*	 * If we successfully wrote any data, and we are not the superuser	 * we clear the setuid and setgid bits as a precaution against	 * tampering.	 */	if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0)		ip->i_ffs_mode &= ~(ISUID | ISGID);	if (error) {		if (ioflag & IO_UNIT) {			(void)VOP_TRUNCATE(vp, osize,			    ioflag & IO_SYNC, ap->a_cred, uio->uio_procp);			uio->uio_offset -= resid - uio->uio_resid;			uio->uio_resid = resid;		}	} else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) {		TIMEVAL_TO_TIMESPEC(&time, &ts);		error = VOP_UPDATE(vp, &ts, &ts, 1);	}	return (error);}