block.c (cbf1dff2f1033cadcb15c0ffc9c0a3d039d8ed42) | block.c (b50cbabc1bc12e6b0082089c70015c1b97db86a1) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 42 unchanged lines hidden (view full) --- 51static BlockDriverAIOCB *bdrv_aio_flush_em(BlockDriverState *bs, 52 BlockDriverCompletionFunc *cb, void *opaque); 53static BlockDriverAIOCB *bdrv_aio_noop_em(BlockDriverState *bs, 54 BlockDriverCompletionFunc *cb, void *opaque); 55static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, 56 uint8_t *buf, int nb_sectors); 57static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, 58 const uint8_t *buf, int nb_sectors); | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 42 unchanged lines hidden (view full) --- 51static BlockDriverAIOCB *bdrv_aio_flush_em(BlockDriverState *bs, 52 BlockDriverCompletionFunc *cb, void *opaque); 53static BlockDriverAIOCB *bdrv_aio_noop_em(BlockDriverState *bs, 54 BlockDriverCompletionFunc *cb, void *opaque); 55static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, 56 uint8_t *buf, int nb_sectors); 57static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, 58 const uint8_t *buf, int nb_sectors); |
59static BlockDriver *find_protocol(const char *filename); | |
60 61static QTAILQ_HEAD(, BlockDriverState) bdrv_states = 62 QTAILQ_HEAD_INITIALIZER(bdrv_states); 63 64static QLIST_HEAD(, BlockDriver) bdrv_drivers = 65 QLIST_HEAD_INITIALIZER(bdrv_drivers); 66 67/* If non-zero, use only whitelisted block drivers */ --- 137 unchanged lines hidden (view full) --- 205 206 return drv->bdrv_create(filename, options); 207} 208 209int bdrv_create_file(const char* filename, QEMUOptionParameter *options) 210{ 211 BlockDriver *drv; 212 | 59 60static QTAILQ_HEAD(, BlockDriverState) bdrv_states = 61 QTAILQ_HEAD_INITIALIZER(bdrv_states); 62 63static QLIST_HEAD(, BlockDriver) bdrv_drivers = 64 QLIST_HEAD_INITIALIZER(bdrv_drivers); 65 66/* If non-zero, use only whitelisted block drivers */ --- 137 unchanged lines hidden (view full) --- 204 205 return drv->bdrv_create(filename, options); 206} 207 208int bdrv_create_file(const char* filename, QEMUOptionParameter *options) 209{ 210 BlockDriver *drv; 211 |
213 drv = find_protocol(filename); | 212 drv = bdrv_find_protocol(filename); |
214 if (drv == NULL) { 215 drv = bdrv_find_format("file"); 216 } 217 218 return bdrv_create(drv, filename, options); 219} 220 221#ifdef _WIN32 --- 56 unchanged lines hidden (view full) --- 278 drv = d; 279 } 280 } 281 } 282 283 return drv; 284} 285 | 213 if (drv == NULL) { 214 drv = bdrv_find_format("file"); 215 } 216 217 return bdrv_create(drv, filename, options); 218} 219 220#ifdef _WIN32 --- 56 unchanged lines hidden (view full) --- 277 drv = d; 278 } 279 } 280 } 281 282 return drv; 283} 284 |
286static BlockDriver *find_protocol(const char *filename) | 285BlockDriver *bdrv_find_protocol(const char *filename) |
287{ 288 BlockDriver *drv1; 289 char protocol[128]; 290 int len; 291 const char *p; 292 int is_drive; 293 294 /* TODO Drivers without bdrv_file_open must be specified explicitly */ --- 178 unchanged lines hidden (view full) --- 473 * Opens a file using a protocol (file, host_device, nbd, ...) 474 */ 475int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags) 476{ 477 BlockDriverState *bs; 478 BlockDriver *drv; 479 int ret; 480 | 286{ 287 BlockDriver *drv1; 288 char protocol[128]; 289 int len; 290 const char *p; 291 int is_drive; 292 293 /* TODO Drivers without bdrv_file_open must be specified explicitly */ --- 178 unchanged lines hidden (view full) --- 472 * Opens a file using a protocol (file, host_device, nbd, ...) 473 */ 474int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags) 475{ 476 BlockDriverState *bs; 477 BlockDriver *drv; 478 int ret; 479 |
481 drv = find_protocol(filename); | 480 drv = bdrv_find_protocol(filename); |
482 if (!drv) { 483 return -ENOENT; 484 } 485 486 bs = bdrv_new(""); 487 ret = bdrv_open_common(bs, filename, flags, drv); 488 if (ret < 0) { 489 bdrv_delete(bs); --- 2018 unchanged lines hidden --- | 481 if (!drv) { 482 return -ENOENT; 483 } 484 485 bs = bdrv_new(""); 486 ret = bdrv_open_common(bs, filename, flags, drv); 487 if (ret < 0) { 488 bdrv_delete(bs); --- 2018 unchanged lines hidden --- |