diff options
author | Volker Lendecke <vl@samba.org> | 2019-03-14 14:23:35 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-03-18 19:21:23 +0000 |
commit | cfc3f32038e9373eeab0a26d2d7b6f4eca2fecc0 (patch) | |
tree | 99526083009391e3312ec477375bede9106fcbaa /source3/libsmb/clifile.c | |
parent | 2040196e10cbcd5746e280ecbc0298b55805ad4c (diff) | |
download | samba-cfc3f32038e9373eeab0a26d2d7b6f4eca2fecc0.tar.gz |
libsmb: Make cli_posix_[sym|hard]link proper tevent_req functions
Simplify adding SMB2 to those functions
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/libsmb/clifile.c')
-rw-r--r-- | source3/libsmb/clifile.c | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 421e26f6086..0afa3cac9c5 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -201,18 +201,49 @@ static void cli_posix_link_internal_done(struct tevent_req *subreq) tevent_req_simple_finish_ntstatus(subreq, status); } +static NTSTATUS cli_posix_link_internal_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); +} + /**************************************************************************** Symlink a file (UNIX extensions). ****************************************************************************/ +struct cli_posix_symlink_state { + uint8_t dummy; +}; + +static void cli_posix_symlink_done(struct tevent_req *subreq); + struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, const char *link_target, const char *newname) { - return cli_posix_link_internal_send( + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_posix_symlink_state *state = NULL; + + req = tevent_req_create( + mem_ctx, &state, struct cli_posix_symlink_state); + if (req == NULL) { + return NULL; + } + + subreq = cli_posix_link_internal_send( mem_ctx, ev, cli, SMB_SET_FILE_UNIX_LINK, link_target, newname); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_posix_symlink_done, req); + return req; +} + +static void cli_posix_symlink_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_posix_link_internal_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); } NTSTATUS cli_posix_symlink_recv(struct tevent_req *req) @@ -408,14 +439,40 @@ NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname, Hard link a file (UNIX extensions). ****************************************************************************/ +struct cli_posix_hardlink_state { + uint8_t dummy; +}; + +static void cli_posix_hardlink_done(struct tevent_req *subreq); + struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, const char *oldname, const char *newname) { - return cli_posix_link_internal_send( - mem_ctx, ev, cli, SMB_SET_FILE_UNIX_HLINK, oldname, newname); + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_posix_hardlink_state *state = NULL; + + req = tevent_req_create( + mem_ctx, &state, struct cli_posix_hardlink_state); + if (req == NULL) { + return NULL; + } + + subreq = cli_posix_link_internal_send( + state, ev, cli, SMB_SET_FILE_UNIX_HLINK, oldname, newname); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_posix_hardlink_done, req); + return req; +} + +static void cli_posix_hardlink_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_posix_link_internal_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); } NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req) |