nfs4: Repair O_TRUNC support

This commit is contained in:
Pawel Dziepak
2012-08-06 19:06:40 +02:00
parent cde3994e69
commit f1fe25e508
2 changed files with 7 additions and 9 deletions
@@ -138,6 +138,13 @@ Inode::Open(int mode, OpenFileCookie* cookie)
} }
} }
if ((mode & O_TRUNC) == O_TRUNC) {
struct stat st;
st.st_size = 0;
WriteStat(&st, B_STAT_SIZE);
file_cache_set_size(fFileCache, 0);
}
cookie->fOpenState = fOpenState; cookie->fOpenState = fOpenState;
cookie->fFileSystem = fFileSystem; cookie->fFileSystem = fFileSystem;
@@ -526,15 +526,6 @@ NFS4Inode::OpenFile(OpenState* state, int mode, OpenDelegationData* delegation)
} }
req.PutFH(fInfo.fParent); req.PutFH(fInfo.fParent);
if ((mode & O_TRUNC) == O_TRUNC) {
AttrValue attr;
attr.fAttribute = FATTR4_SIZE;
attr.fFreePointer = false;
attr.fData.fValue64 = 0;
req.Open(CLAIM_NULL, sequence, sModeToAccess(mode),
state->fClientID, OPEN4_CREATE, fFileSystem->OpenOwner(),
fInfo.fName, &attr, 1, false);
} else
req.Open(CLAIM_NULL, sequence, sModeToAccess(mode), state->fClientID, req.Open(CLAIM_NULL, sequence, sModeToAccess(mode), state->fClientID,
OPEN4_NOCREATE, fFileSystem->OpenOwner(), fInfo.fName); OPEN4_NOCREATE, fFileSystem->OpenOwner(), fInfo.fName);
req.GetFH(); req.GetFH();