[PATCH] small ones for clifuse
Volker Lendecke
vl at samba.org
Mon Mar 13 18:18:16 UTC 2017
Hi!
Review appreciated!
Thanks, Volker
-------------- next part --------------
>From 6c1ccf36d9b6f9cc2fcb2cf039c2d39eadffab3f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 13 Mar 2017 17:48:56 +0100
Subject: [PATCH 1/2] examples: Add '-p', '--port' to smb2mount
Signed-off-by: Volker Lendecke <vl at samba.org>
---
examples/fuse/smb2mount.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/examples/fuse/smb2mount.c b/examples/fuse/smb2mount.c
index b90e115..4ed985f 100644
--- a/examples/fuse/smb2mount.c
+++ b/examples/fuse/smb2mount.c
@@ -26,7 +26,8 @@
#include "clifuse.h"
static struct cli_state *connect_one(const struct user_auth_info *auth_info,
- const char *server, const char *share)
+ const char *server, int port,
+ const char *share)
{
struct cli_state *c = NULL;
NTSTATUS nt_status;
@@ -38,7 +39,7 @@ static struct cli_state *connect_one(const struct user_auth_info *auth_info,
}
nt_status = cli_full_connection(&c, lp_netbios_name(), server,
- NULL, 0,
+ NULL, port,
share, "?????",
get_cmdline_auth_info_username(auth_info),
lp_workgroup(),
@@ -73,6 +74,7 @@ int main(int argc, char *argv[])
TALLOC_CTX *frame = talloc_stackframe();
poptContext pc;
int opt, ret;
+ int port = 0;
char *unc, *mountpoint, *server, *share;
struct cli_state *cli;
@@ -80,6 +82,8 @@ int main(int argc, char *argv[])
POPT_AUTOHELP
POPT_COMMON_SAMBA
POPT_COMMON_CREDENTIALS
+ { "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to",
+ "PORT" },
POPT_TABLEEND
};
@@ -96,6 +100,8 @@ int main(int argc, char *argv[])
while ((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
+ case 'p':
+ break;
default:
fprintf(stderr, "Unknown Option: %c\n", opt);
exit(1);
@@ -137,7 +143,7 @@ int main(int argc, char *argv[])
*share = 0;
share++;
- cli = connect_one(cmdline_auth_info, server, share);
+ cli = connect_one(cmdline_auth_info, server, port, share);
if (cli == NULL) {
return -1;
}
--
2.1.4
>From 8099533f35a9c3cdd862381592dc478971de9002 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 13 Mar 2017 19:09:27 +0100
Subject: [PATCH 2/2] clifuse: Add getattr stub
Signed-off-by: Volker Lendecke <vl at samba.org>
---
examples/fuse/clifuse.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index fc57ec7..da9dd4d 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,
--
2.1.4
More information about the samba-technical
mailing list