struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode);
struct vrequest treq;
cred_t *credp = crref();
+ afs_offs_t toffs;
AFS_GLOCK();
code = -code;
else {
#ifdef AFS_64BIT_CLIENT
- if (*offp + count > afs_vmMappingEnd) {
+ toffs = *offp;
+ if (fp->f_flags & O_APPEND)
+ toffs += vcp->m.Length;
+ if (toffs + count > afs_vmMappingEnd) {
uio_t tuio;
struct iovec iov;
afs_size_t oldOffset = *offp;
afs_int32 xfered = 0;
- if (*offp < afs_vmMappingEnd) {
+ if (toffs < afs_vmMappingEnd) {
/* special case of a buffer crossing the VM mapping end */
afs_int32 tcount = afs_vmMappingEnd - *offp;
count -= tcount;
goto done;
}
xfered = tcount;
+ toffs += tcount;
}
- setup_uio(&tuio, &iov, buf + xfered, (afs_offs_t) *offp, count,
+ setup_uio(&tuio, &iov, buf + xfered, (afs_offs_t) toffs, count,
UIO_WRITE, AFS_UIOSYS);
code = afs_write(vcp, &tuio, fp->f_flags, credp, 0);
xfered += count - tuio.uio_resid;
}
code = xfered;
*offp += count;
+ toffs += count;
ObtainWriteLock(&vcp->lock,400);
vcp->m.Date = osi_Time(); /* Set file date (for ranlib) */
/* extend file */
- if (*offp > vcp->m.Length) {
- vcp->m.Length = *offp;
+ if (!(fp->f_flags & O_APPEND) && toffs > vcp->m.Length) {
+ vcp->m.Length = toffs;
}
ReleaseWriteLock(&vcp->lock);
}