{
static access3res result;
- result.status = NFS3ERR_NOTSUPP;
+ BlueSkyInode *inode = lookup_fh(&argp->object);
+ if (inode == NULL) {
+ result.status = NFS3ERR_STALE;
+ result.access3res_u.resfail.present = FALSE;
+ return &result;
+ }
+
+ result.status = NFS3_OK;
+ result.access3res_u.resok.obj_attributes.present = TRUE;
+ encode_fattr3(&result.access3res_u.resok.obj_attributes.post_op_attr_u.attributes, inode);
+ result.access3res_u.resok.access = argp->access;
return &result;
}
return &result;
}
+gint bluesky_dirent_compare(gconstpointer a, gconstpointer b,
+ gpointer unused);
+
readdir3res *
nfsproc3_readdir_3_svc(readdir3args *argp, struct svc_req *rqstp)
{
static readdir3res result;
- result.status = NFS3ERR_NOTSUPP;
+ BlueSkyInode *dir = lookup_fh(&argp->dir);
+ if (dir == NULL) {
+ result.status = NFS3ERR_STALE;
+ result.readdir3res_u.resfail.present = FALSE;
+ return &result;
+ }
+
+ result.status = NFS3_OK;
+ result.readdir3res_u.resok.dir_attributes.present = TRUE;
+ encode_fattr3(&result.readdir3res_u.resok.dir_attributes.post_op_attr_u.attributes, dir);
+ memset(result.readdir3res_u.resok.cookieverf, 0,
+ sizeof(result.readdir3res_u.resok.cookieverf));
+
+#define MAX_READDIR_DIRENTS 4
+ static entry3 dirents[MAX_READDIR_DIRENTS];
+ int count = 0;
+
+ BlueSkyDirent start = {NULL, argp->cookie, 0};
+ GSequenceIter *i = g_sequence_search(dir->dirents, &start,
+ bluesky_dirent_compare, NULL);
+
+ while (count < MAX_READDIR_DIRENTS && !g_sequence_iter_is_end(i)) {
+ BlueSkyDirent *d = g_sequence_get(i);
+ dirents[count].fileid = d->inum;
+ dirents[count].name = d->name;
+ dirents[count].cookie = d->hash;
+ 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)
+ result.readdir3res_u.resok.reply.entries = &dirents[0];
+ else
+ result.readdir3res_u.resok.reply.entries = NULL;
+ result.readdir3res_u.resok.reply.eof = g_sequence_iter_is_end(i);
return &result;
}
g_thread_init(NULL);
register_rpc();
+ fs = bluesky_new_fs("export");
+
BlueSkyInode *root;
root = bluesky_new_inode(BLUESKY_ROOT_INUM, BLUESKY_DIRECTORY);
root->nlink = 1;
root->mode = 0755;
bluesky_insert_inode(fs, root);
- svc_run ();
- fprintf (stderr, "%s", "svc_run returned");
- exit (1);
- /* NOTREACHED */
+ BlueSkyInode *file;
+ file = bluesky_new_inode(bluesky_fs_alloc_inode(fs), BLUESKY_REGULAR);
+ file->nlink = 1;
+ file->mode = 0755;
+ bluesky_insert_inode(fs, file);
+ bluesky_directory_insert(root, "demo", file->inum);
+
+ svc_run();
+ fprintf(stderr, "%s", "svc_run returned");
+ exit(1);
}