diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-13 20:37:47 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-13 20:37:47 +0100 |
commit | e99ffb4b0b09d883666e621eba0bb41ac4233d9f (patch) | |
tree | 7691b2b877ae7df29eaabe30b75f35bc86b63295 /default.c | |
parent | 9c14774f2b6b22628a8b57b7a1e5edec1e236f9c (diff) | |
download | fastwriter-e99ffb4b0b09d883666e621eba0bb41ac4233d9f.tar.gz fastwriter-e99ffb4b0b09d883666e621eba0bb41ac4233d9f.tar.bz2 fastwriter-e99ffb4b0b09d883666e621eba0bb41ac4233d9f.tar.xz fastwriter-e99ffb4b0b09d883666e621eba0bb41ac4233d9f.zip |
Properly detect /dev/null as raw device and do not set DIRECT flag on raw devices
Diffstat (limited to 'default.c')
-rw-r--r-- | default.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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; |