Revision 6a8dc042 block/raw-posix.c
b/block/raw-posix.c | ||
---|---|---|
185 | 185 |
} |
186 | 186 |
#endif |
187 | 187 |
|
188 |
static void raw_parse_flags(int bdrv_flags, int *open_flags) |
|
189 |
{ |
|
190 |
assert(open_flags != NULL); |
|
191 |
|
|
192 |
*open_flags |= O_BINARY; |
|
193 |
*open_flags &= ~O_ACCMODE; |
|
194 |
if (bdrv_flags & BDRV_O_RDWR) { |
|
195 |
*open_flags |= O_RDWR; |
|
196 |
} else { |
|
197 |
*open_flags |= O_RDONLY; |
|
198 |
} |
|
199 |
|
|
200 |
/* Use O_DSYNC for write-through caching, no flags for write-back caching, |
|
201 |
* and O_DIRECT for no caching. */ |
|
202 |
if ((bdrv_flags & BDRV_O_NOCACHE)) { |
|
203 |
*open_flags |= O_DIRECT; |
|
204 |
} |
|
205 |
if (!(bdrv_flags & BDRV_O_CACHE_WB)) { |
|
206 |
*open_flags |= O_DSYNC; |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
188 | 210 |
#ifdef CONFIG_LINUX_AIO |
189 | 211 |
static int raw_set_aio(void **aio_ctx, int *use_aio, int bdrv_flags) |
190 | 212 |
{ |
... | ... | |
228 | 250 |
return ret; |
229 | 251 |
} |
230 | 252 |
|
231 |
s->open_flags = open_flags | O_BINARY; |
|
232 |
s->open_flags &= ~O_ACCMODE; |
|
233 |
if (bdrv_flags & BDRV_O_RDWR) { |
|
234 |
s->open_flags |= O_RDWR; |
|
235 |
} else { |
|
236 |
s->open_flags |= O_RDONLY; |
|
237 |
} |
|
238 |
|
|
239 |
/* Use O_DSYNC for write-through caching, no flags for write-back caching, |
|
240 |
* and O_DIRECT for no caching. */ |
|
241 |
if ((bdrv_flags & BDRV_O_NOCACHE)) |
|
242 |
s->open_flags |= O_DIRECT; |
|
243 |
if (!(bdrv_flags & BDRV_O_CACHE_WB)) |
|
244 |
s->open_flags |= O_DSYNC; |
|
253 |
s->open_flags = open_flags; |
|
254 |
raw_parse_flags(bdrv_flags, &s->open_flags); |
|
245 | 255 |
|
246 | 256 |
s->fd = -1; |
247 | 257 |
fd = qemu_open(filename, s->open_flags, 0644); |
Also available in: Unified diff