summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--default.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/default.c b/default.c
index 97baec1..5109608 100644
--- a/default.c
+++ b/default.c
@@ -117,7 +117,19 @@ int fastwriter_default_open(fastwriter_t *fw, const char *name, fastwriter_flags
open_flags |= O_TRUNC;
ctx->fd = open(name, open_flags, open_mode);
- if (ctx->fd < 0) return errno;
+#ifdef SYNC_MODE
+ if (ctx->fd < 0) {
+ // Running as normal user, try to disable direct mode
+ if ((errno == EINVAL)&&(ctx->sync_mode)) {
+ ctx->sync_mode = 0;
+ open_flags &= ~O_DIRECT;
+ ctx->fd = open(name, open_flags, open_mode);
+ }
+#endif /* SYNC_MODE */
+ if (ctx->fd < 0) return errno;
+#ifdef SYNC_MODE
+ }
+#endif /* SYNC_MODE */
if (((open_flags&FASTWRITER_FLAGS_OVERWRITE)==0)&&(strcmp(fs, "raw"))) {
ctx->prior_size = lseek(ctx->fd, 0, SEEK_END);