X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=nfs3%2Fnfs3.c;h=04a77b62b0090c2396dcb0fa4f39c99779eadd7a;hb=19f316a185dc3d2a67fc3d3546f3989e45559d7c;hp=e4646842eb5e8d2ba2980e5701880ceb9ee8cb04;hpb=988bf74dd44cd57d0b67aa2a7f1bf77e09c24484;p=bluesky.git diff --git a/nfs3/nfs3.c b/nfs3/nfs3.c index e464684..04a77b6 100644 --- a/nfs3/nfs3.c +++ b/nfs3/nfs3.c @@ -140,6 +140,7 @@ nfsproc3_lookup_3_svc(diropargs3 *argp, struct svc_req *rqstp) return &result; } + result.status = NFS3_OK; result.lookup3res_u.resok.dir_attributes.present = TRUE; encode_fattr3(&result.lookup3res_u.resok.dir_attributes.post_op_attr_u.attributes, dir); result.lookup3res_u.resok.obj_attributes.present = TRUE; @@ -197,8 +198,33 @@ write3res * 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; } @@ -237,6 +263,11 @@ nfsproc3_create_3_svc(create3args *argp, struct svc_req *rqstp) file = bluesky_new_inode(bluesky_fs_alloc_inode(fs), BLUESKY_REGULAR); file->nlink = 1; file->mode = 0755; + int64_t time = bluesky_get_current_time(); + printf("time: %lld\n", time); + file->mtime = time; + file->ctime = time; + file->atime = time; bluesky_insert_inode(fs, file); bluesky_directory_insert(dir, argp->where.name, file->inum); @@ -358,13 +389,12 @@ nfsproc3_readdir_3_svc(readdir3args *argp, struct svc_req *rqstp) 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]; i = g_sequence_iter_next(i); count++; - printf("readdir: %s %lld\n", d->name, d->inum); } if (count > 0)