summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-07-13 09:37:40 +0200
committerJeremy Allison <jra@samba.org>2012-07-18 15:47:13 -0700
commitdc5e3fba488fc99dcd984e37d6f05ac22a773b47 (patch)
tree4b199ae0a6be2e20864b7696f9e93b22606beb5a
parentfd351b6ebbb1b1447b7f8ab3081b762dde53709e (diff)
downloadsamba-dc5e3fba488fc99dcd984e37d6f05ac22a773b47.tar.gz
samba-dc5e3fba488fc99dcd984e37d6f05ac22a773b47.tar.bz2
samba-dc5e3fba488fc99dcd984e37d6f05ac22a773b47.zip
s3-libasys: Add asys_fsync() implementation
Signed-off-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source3/lib/asys/asys.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source3/lib/asys/asys.c b/source3/lib/asys/asys.c
index 766a716f9a..9937d2482d 100644
--- a/source3/lib/asys/asys.c
+++ b/source3/lib/asys/asys.c
@@ -35,9 +35,14 @@ struct asys_pread_args {
off_t offset;
};
+struct asys_fsync_args {
+ int fildes;
+};
+
union asys_job_args {
struct asys_pwrite_args pwrite_args;
struct asys_pread_args pread_args;
+ struct asys_fsync_args fsync_args;
};
struct asys_job {
@@ -232,6 +237,44 @@ static void asys_pread_do(void *private_data)
}
}
+static void asys_fsync_do(void *private_data);
+
+int asys_fsync(struct asys_context *ctx, int fildes, void *private_data)
+{
+ struct asys_job *job;
+ struct asys_fsync_args *args;
+ int jobid;
+ int ret;
+
+ ret = asys_new_job(ctx, &jobid, &job);
+ if (ret != 0) {
+ return ret;
+ }
+ job->private_data = private_data;
+
+ args = &job->args.fsync_args;
+ args->fildes = fildes;
+
+ ret = pthreadpool_add_job(ctx->pool, jobid, asys_fsync_do, job);
+ if (ret != 0) {
+ return ret;
+ }
+ job->busy = 1;
+
+ return 0;
+}
+
+static void asys_fsync_do(void *private_data)
+{
+ struct asys_job *job = (struct asys_job *)private_data;
+ struct asys_fsync_args *args = &job->args.fsync_args;
+
+ job->ret = fsync(args->fildes);
+ if (job->ret == -1) {
+ job->err = errno;
+ }
+}
+
void asys_cancel(struct asys_context *ctx, void *private_data)
{
unsigned i;