diff options
author | Volker Lendecke <vl@samba.org> | 2012-06-26 14:30:59 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-07-18 13:49:21 -0700 |
commit | c6e456d9c08eb0d05904802e0f23f15676a13e0d (patch) | |
tree | 6066546f482f0dc83285fb5aec0639d4d98d5053 /source3/modules | |
parent | d44ccdd4378d6aafd1dd6322e419d1165635f25b (diff) | |
download | samba-c6e456d9c08eb0d05904802e0f23f15676a13e0d.tar.gz samba-c6e456d9c08eb0d05904802e0f23f15676a13e0d.tar.bz2 samba-c6e456d9c08eb0d05904802e0f23f15676a13e0d.zip |
s3-vfs: async pwrite
Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/vfs_default.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f8c5b75977..2235ef98a9 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -29,6 +29,7 @@ #include "passdb/lookup_sid.h" #include "source3/include/msdfs.h" #include "librpc/gen_ndr/ndr_dfsblobs.h" +#include "lib/util/tevent_unix.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS @@ -628,6 +629,51 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons return result; } +struct vfswrap_pwrite_state { + ssize_t retval; +}; + +static struct tevent_req *vfswrap_pwrite_send( + struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, struct tevent_context *ev, + struct files_struct *fsp, const void *data, size_t n, off_t offset) +{ + struct tevent_req *req; + struct vfswrap_pwrite_state *state; + int saved_errno; + + req = tevent_req_create(mem_ctx, &state, + struct vfswrap_pwrite_state); + if (req == NULL) { + return NULL; + } + + START_PROFILE_BYTES(syscall_pwrite, n); + state->retval = sys_pwrite(fsp->fh->fd, data, n, offset); + saved_errno = errno; + END_PROFILE(syscall_pwrite); + + if (state->retval == -1) { + tevent_req_error(req, saved_errno); + } else { + tevent_req_done(req); + } + return tevent_req_post(req, ev); +} + +static ssize_t vfswrap_pwrite_recv(struct tevent_req *req, int *perrno) +{ + struct vfswrap_pwrite_state *state = tevent_req_data( + req, struct vfswrap_pwrite_state); + int err; + + if (tevent_req_is_unix_error(req, &err)) { + *perrno = err; + return -1; + } + return state->retval; +} + static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence) { off_t result = 0; @@ -2211,6 +2257,8 @@ static struct vfs_fn_pointers vfs_default_fns = { .pread_fn = vfswrap_pread, .write_fn = vfswrap_write, .pwrite_fn = vfswrap_pwrite, + .pwrite_send_fn = vfswrap_pwrite_send, + .pwrite_recv_fn = vfswrap_pwrite_recv, .lseek_fn = vfswrap_lseek, .sendfile_fn = vfswrap_sendfile, .recvfile_fn = vfswrap_recvfile, |