nfs4: Repair O_TRUNC support
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user