summaryrefslogtreecommitdiffstats
path: root/default.c
diff options
context:
space:
mode:
Diffstat (limited to 'default.c')
-rw-r--r--default.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/default.c b/default.c
index 02b9f6a..6f9d1cb 100644
--- a/default.c
+++ b/default.c
@@ -61,7 +61,7 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
fastwriter_default_t *ctx;
- err = get_file_fs(name, sizeof(fs) - 1, fs);
+ err = fastwriter_get_file_fs(name, sizeof(fs) - 1, fs);
if (err) return err;
ctx = (fastwriter_default_t*)malloc(sizeof(fastwriter_default_t));
@@ -72,7 +72,6 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
fw->ctx = ctx;
#ifdef SYNC_MODE
- open_flags |= O_DIRECT;
ctx->sync_mode = 1;
#endif /* SYNC_MODE */
@@ -82,6 +81,9 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
ctx->wr_block = EXT4_WRITEBLOCK;
ctx->pa_block = 0;
ctx->prior_size = (size_t)-1;
+#ifdef SYNC_MODE
+ ctx->sync_mode = 0;
+#endif /* SYNC_MODE */
} else if (!strcmp(fs, "ext4")) {
ctx->wr_block = EXT4_WRITEBLOCK;
ctx->pa_block = EXT4_PREALLOCATE;
@@ -96,6 +98,12 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
ctx->pa_block = 0;
}
+#ifdef SYNC_MODE
+ if (ctx->sync_mode) {
+ open_flags |= O_DIRECT;
+ }
+#endif /* SYNC_MODE */
+
if (flags&FASTWRITER_FLAGS_OVERWRITE)
open_flags |= O_TRUNC;
@@ -180,7 +188,6 @@ int fastwriter_default_write(fastwriter_t *fw, fastwriter_write_flags_t flags, s
do {
res = write(ctx->fd, data + sum, size + delta - sum);
-// printf("%i %i %p %zu %i\n", res, ctx->fd, data, size, delta);
if (res < 0) {
*written = sum;
return errno;