return inode;
}
+int64_t decode_nfstime3(nfstime3 *time)
+{
+ int64_t result = (int64_t)time->seconds * 1000000;
+ result += time->nseconds / 1000;
+ return result;
+}
+
/* Copy inode attributes into NFS response. The BlueSkyInode should be locked
* by the caller. */
void encode_fattr3(struct fattr3 *result, BlueSkyInode *inode)
{
static wccstat3 result;
- result.status = NFS3ERR_NOTSUPP;
+ result.wccstat3_u.wcc.before.present = FALSE;
+ result.wccstat3_u.wcc.after.present = FALSE;
+ BlueSkyInode *inode = lookup_fh(&argp->object);
+ if (inode == NULL) {
+ result.status = NFS3ERR_STALE;
+ return &result;
+ }
+
+ encode_pre_wcc(&result.wccstat3_u.wcc, inode);
+ if (argp->guard.check) {
+ if (inode->ctime != decode_nfstime3(&argp->guard.sattrguard3_u.ctime)) {
+ result.status = NFS3ERR_NOT_SYNC;
+ result.wccstat3_u.wcc.after.present = TRUE;
+ encode_fattr3(&result.wccstat3_u.wcc.after.post_op_attr_u.attributes, inode);
+ return &result;
+ }
+ }
+
+ if (argp->new_attributes.mode.set) {
+ inode->mode = argp->new_attributes.mode.set_uint32_u.val;
+ }
+
+ if (argp->new_attributes.uid.set) {
+ inode->uid = argp->new_attributes.uid.set_uint32_u.val;
+ }
+
+ if (argp->new_attributes.gid.set) {
+ inode->gid = argp->new_attributes.gid.set_uint32_u.val;
+ }
+
+ int64_t now = bluesky_get_current_time();
+
+ if (argp->new_attributes.size.set) {
+ bluesky_file_truncate(inode,
+ argp->new_attributes.size.set_uint64_u.val);
+ inode->mtime = now;
+ }
+
+ switch (argp->new_attributes.atime.set) {
+ case DONT_CHANGE:
+ break;
+ case SET_TO_SERVER_TIME:
+ inode->atime = now;
+ break;
+ case SET_TO_CLIENT_TIME:
+ inode->atime = decode_nfstime3(&argp->new_attributes.atime.set_time_u.time);
+ break;
+ }
+
+ switch (argp->new_attributes.mtime.set) {
+ case DONT_CHANGE:
+ break;
+ case SET_TO_SERVER_TIME:
+ inode->mtime = now;
+ break;
+ case SET_TO_CLIENT_TIME:
+ inode->mtime = decode_nfstime3(&argp->new_attributes.mtime.set_time_u.time);
+ break;
+ }
+
+ inode->ctime = now;
+ inode->change_count++;
+
+ result.wccstat3_u.wcc.after.present = TRUE;
+ encode_fattr3(&result.wccstat3_u.wcc.after.post_op_attr_u.attributes,
+ inode);
+ result.status = NFS3_OK;
return &result;
}