diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2012-03-26 15:00:45 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2012-03-26 15:00:45 +0200 |
commit | 0af5dbbe4edec6a25cc4a66248bee38f570d131e (patch) | |
tree | f4ac495eff92fb47f0cf3795e497b668015486b7 | |
parent | 4fdf54d4690fdf33c94b27bcf44094bb933e11fd (diff) | |
download | fastwriter-0af5dbbe4edec6a25cc4a66248bee38f570d131e.tar.gz fastwriter-0af5dbbe4edec6a25cc4a66248bee38f570d131e.tar.bz2 fastwriter-0af5dbbe4edec6a25cc4a66248bee38f570d131e.tar.xz fastwriter-0af5dbbe4edec6a25cc4a66248bee38f570d131e.zip |
Try without O_DIRECT if run under normal user
-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); |