1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

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
This commit is contained in:
Volker Lendecke 2017-03-13 19:09:27 +01:00 committed by Andreas Schneider
parent 6b8e599310
commit 64b20a1d42

View File

@ -717,6 +717,72 @@ static void cli_ll_lookup_done(struct tevent_req *req)
TALLOC_FREE(state); 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 ll_open_state {
struct mount_state *mstate; struct mount_state *mstate;
fuse_req_t freq; 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 = { static struct fuse_lowlevel_ops cli_ll_ops = {
.lookup = cli_ll_lookup, .lookup = cli_ll_lookup,
.getattr = cli_ll_getattr,
.open = cli_ll_open, .open = cli_ll_open,
.create = cli_ll_create, .create = cli_ll_create,
.release = cli_ll_release, .release = cli_ll_release,