/alps/fastwriter

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/fastwriter

« back to all changes in this revision

Viewing changes to default.c

  • Committer: Suren A. Chilingaryan
  • Date: 2011-12-13 19:37:47 UTC
  • Revision ID: csa@dside.dyndns.org-20111213193747-g8ld48dh1kwypice
Properly detect /dev/null as raw device and do not set DIRECT flag on raw devices

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    
62
62
    fastwriter_default_t *ctx;
63
63
 
64
 
    err = get_file_fs(name, sizeof(fs) - 1, fs);
 
64
    err = fastwriter_get_file_fs(name, sizeof(fs) - 1, fs);
65
65
    if (err) return err;
66
66
    
67
67
    ctx = (fastwriter_default_t*)malloc(sizeof(fastwriter_default_t));
72
72
    fw->ctx = ctx;
73
73
 
74
74
#ifdef SYNC_MODE
75
 
    open_flags |= O_DIRECT;
76
75
    ctx->sync_mode = 1;
77
76
#endif /* SYNC_MODE */
78
77
 
82
81
        ctx->wr_block = EXT4_WRITEBLOCK;
83
82
        ctx->pa_block = 0;
84
83
        ctx->prior_size = (size_t)-1;
 
84
#ifdef SYNC_MODE
 
85
        ctx->sync_mode = 0;
 
86
#endif /* SYNC_MODE */
85
87
    } else if (!strcmp(fs, "ext4")) {
86
88
        ctx->wr_block = EXT4_WRITEBLOCK;
87
89
        ctx->pa_block = EXT4_PREALLOCATE;
96
98
        ctx->pa_block = 0;
97
99
    }
98
100
    
 
101
#ifdef SYNC_MODE
 
102
    if (ctx->sync_mode) {
 
103
        open_flags |= O_DIRECT;
 
104
    }
 
105
#endif /* SYNC_MODE */
 
106
 
99
107
    if (flags&FASTWRITER_FLAGS_OVERWRITE)
100
108
        open_flags |= O_TRUNC;
101
109
 
180
188
    
181
189
    do {
182
190
        res = write(ctx->fd, data + sum, size + delta - sum);
183
 
//      printf("%i %i %p %zu %i\n", res, ctx->fd, data, size, delta);
184
191
        if (res < 0) {
185
192
            *written = sum;
186
193
            return errno;