diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/VFS/skel_opaque.c | 17 | ||||
-rw-r--r-- | examples/VFS/skel_transparent.c | 56 |
2 files changed, 73 insertions, 0 deletions
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 89d69928eb..56f3b977ac 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -188,6 +188,21 @@ static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, void *da return -1; } +static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct files_struct *fsp, + void *data, size_t n, off_t offset) +{ + return NULL; +} + +static ssize_t skel_pread_recv(struct tevent_req *req, int *err) +{ + *err = ENOSYS; + return -1; +} + static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n) { errno = ENOSYS; @@ -805,6 +820,8 @@ struct vfs_fn_pointers skel_opaque_fns = { .close_fn = skel_close_fn, .read_fn = skel_vfs_read, .pread_fn = skel_pread, + .pread_send_fn = skel_pread_send, + .pread_recv_fn = skel_pread_recv, .write_fn = skel_write, .pwrite_fn = skel_pwrite, .lseek_fn = skel_lseek, diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 8f55d6aa8a..55149d7fd8 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -23,6 +23,7 @@ #include "../source3/include/includes.h" +#include "lib/util/tevent_unix.h" /* PLEASE,PLEASE READ THE VFS MODULES CHAPTER OF THE SAMBA DEVELOPERS GUIDE!!!!!! @@ -193,6 +194,59 @@ static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, void *da return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); } +struct skel_pread_state { + ssize_t ret; + int err; +}; + +static void skel_pread_done(struct tevent_req *subreq); + +static struct tevent_req *skel_pread_send(struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct files_struct *fsp, + void *data, size_t n, off_t offset) +{ + struct tevent_req *req, *subreq; + struct skel_pread_state *state; + + req = tevent_req_create(mem_ctx, &state, struct skel_pread_state); + if (req == NULL) { + return NULL; + } + subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data, + n, offset); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, skel_pread_done, req); + return req; +} + +static void skel_pread_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct skel_pread_state *state = tevent_req_data( + req, struct skel_pread_state); + + state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err); + TALLOC_FREE(subreq); + tevent_req_done(req); +} + +static ssize_t skel_pread_recv(struct tevent_req *req, int *err) +{ + struct skel_pread_state *state = tevent_req_data( + req, struct skel_pread_state); + + if (tevent_req_is_unix_error(req, err)) { + return -1; + } + *err = state->err; + return state->ret; +} + static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n) { return SMB_VFS_NEXT_WRITE(handle, fsp, data, n); @@ -765,6 +819,8 @@ struct vfs_fn_pointers skel_transparent_fns = { .close_fn = skel_close_fn, .read_fn = skel_vfs_read, .pread_fn = skel_pread, + .pread_send_fn = skel_pread_send, + .pread_recv_fn = skel_pread_recv, .write_fn = skel_write, .pwrite_fn = skel_pwrite, .lseek_fn = skel_lseek, |