nfsproc3_write_3_svc(write3args *argp, struct svc_req *rqstp)
{
static write3res result;
+ struct wcc_data wcc;
+ memset(&wcc, 0, sizeof(wcc));
- result.status = NFS3ERR_NOTSUPP;
+ BlueSkyInode *inode = lookup_fh(&argp->file);
+ if (inode == NULL) {
+ result.status = NFS3ERR_STALE;
+ result.write3res_u.resfail = wcc;
+ return &result;
+ }
+
+ encode_pre_wcc(&wcc, inode);
+ if (inode->type != BLUESKY_REGULAR) {
+ result.status = NFS3ERR_INVAL;
+ result.write3res_u.resfail = wcc;
+ return &result;
+ }
+
+ uint64_t lastbyte = argp->offset + argp->count;
+ if (lastbyte > inode->size) {
+ bluesky_file_truncate(inode, lastbyte);
+ }
+ inode->change_count++;
+
+ encode_fattr3(&wcc.after.post_op_attr_u.attributes, inode);
+ result.write3res_u.resok.file_wcc = wcc;
+ result.write3res_u.resok.count = argp->count;
+ result.write3res_u.resok.committed = FILE_SYNC;
return &result;
}
BlueSkyDirent *d = g_sequence_get(i);
dirents[count].fileid = d->inum;
dirents[count].name = d->name;
- dirents[count].cookie = d->hash;
+ dirents[count].cookie = d->cookie;
dirents[count].nextentry = NULL;
if (count > 0)
dirents[count - 1].nextentry = &dirents[count];