summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2017-03-13 19:09:27 +0100
committerAndreas Schneider <asn@cryptomilk.org>2017-03-14 19:15:03 +0100
commit64b20a1d42064854faa697b9e53d695601bba42f (patch)
tree09d9de5d8cacdd3d6dc4ec10835d14f5a478f80b /examples
parent6b8e599310ae1ac72f1eacc9f3bd4749367db442 (diff)
downloadsamba-64b20a1d42064854faa697b9e53d695601bba42f.tar.gz
examples:clifuse: Add a stub for getattr
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Mar 14 19:15:03 CET 2017 on sn-devel-144
Diffstat (limited to 'examples')
-rw-r--r--examples/fuse/clifuse.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index fc57ec7dcc0..da9dd4d3e82 100644
--- a/examples/fuse/clifuse.c
+++ b/examples/fuse/clifuse.c
@@ -717,6 +717,72 @@ static void cli_ll_lookup_done(struct tevent_req *req)
TALLOC_FREE(state);
}
+struct ll_getattr_state {
+ struct mount_state *mstate;
+ fuse_req_t freq;
+ struct fuse_file_info fi;
+};
+
+static void cli_ll_getattr_done(struct tevent_req *req);
+
+static void cli_ll_getattr(fuse_req_t freq, fuse_ino_t ino,
+ struct fuse_file_info *fi)
+{
+ struct mount_state *mstate = talloc_get_type_abort(
+ fuse_req_userdata(freq), struct mount_state);
+ struct ll_getattr_state *state;
+ struct inode_state *istate;
+ struct tevent_req *req;
+
+ DBG_DEBUG("ino=%ju\n", (uintmax_t)ino);
+
+ istate = idr_find(mstate->ino_ctx, ino);
+ if (istate == NULL) {
+ fuse_reply_err(freq, ENOENT);
+ return;
+ }
+
+ state = talloc(mstate, struct ll_getattr_state);
+ if (state == NULL) {
+ fuse_reply_err(freq, ENOMEM);
+ return;
+ }
+ state->mstate = mstate;
+ state->freq = freq;
+
+ req = cli_get_unixattr_send(state, mstate->ev, mstate->cli,
+ istate->path);
+ if (req == NULL) {
+ TALLOC_FREE(state);
+ fuse_reply_err(freq, ENOMEM);
+ return;
+ }
+ tevent_req_set_callback(req, cli_ll_getattr_done, state);
+}
+
+static void cli_ll_getattr_done(struct tevent_req *req)
+{
+ struct ll_getattr_state *state = tevent_req_callback_data(
+ req, struct ll_getattr_state);
+ struct stat st;
+ NTSTATUS status;
+ int ret;
+
+ status = cli_get_unixattr_recv(req, &st);
+ TALLOC_FREE(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ fuse_reply_err(state->freq, map_errno_from_nt_status(status));
+ return;
+ }
+
+ ret = fuse_reply_attr(state->freq, &st, 1);
+ if (ret != 0) {
+ DBG_NOTICE("fuse_reply_attr failed: %s\n",
+ strerror(-errno));
+ }
+}
+
+
struct ll_open_state {
struct mount_state *mstate;
fuse_req_t freq;
@@ -1302,6 +1368,7 @@ static void cli_ll_releasedir_done(struct tevent_req *req)
static struct fuse_lowlevel_ops cli_ll_ops = {
.lookup = cli_ll_lookup,
+ .getattr = cli_ll_getattr,
.open = cli_ll_open,
.create = cli_ll_create,
.release = cli_ll_release,