diff options
Diffstat (limited to 'default.c')
-rw-r--r-- | default.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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); |