Commit 1cec71e3597b6ab8df939dff90cc05515d0f0272
1 parent
c6a5a71a
Revert "support colon in filenames"
This reverts commit 707c0dbc. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
6 changed files
with
11 additions
and
48 deletions
block.c
| ... | ... | @@ -225,7 +225,7 @@ static BlockDriver *find_protocol(const char *filename) |
| 225 | 225 | { |
| 226 | 226 | BlockDriver *drv1; |
| 227 | 227 | char protocol[128]; |
| 228 | - int len = qemu_strnlen(filename, 127) + 1; | |
| 228 | + int len; | |
| 229 | 229 | const char *p; |
| 230 | 230 | |
| 231 | 231 | #ifdef _WIN32 |
| ... | ... | @@ -233,9 +233,14 @@ static BlockDriver *find_protocol(const char *filename) |
| 233 | 233 | is_windows_drive_prefix(filename)) |
| 234 | 234 | return bdrv_find_format("raw"); |
| 235 | 235 | #endif |
| 236 | - p = fill_token(protocol, len, filename, ':'); | |
| 237 | - if (*p != ':') | |
| 236 | + p = strchr(filename, ':'); | |
| 237 | + if (!p) | |
| 238 | 238 | return bdrv_find_format("raw"); |
| 239 | + len = p - filename; | |
| 240 | + if (len > sizeof(protocol) - 1) | |
| 241 | + len = sizeof(protocol) - 1; | |
| 242 | + memcpy(protocol, filename, len); | |
| 243 | + protocol[len] = '\0'; | |
| 239 | 244 | for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) { |
| 240 | 245 | if (drv1->protocol_name && |
| 241 | 246 | !strcmp(drv1->protocol_name, protocol)) |
| ... | ... | @@ -409,9 +414,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
| 409 | 414 | open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); |
| 410 | 415 | else |
| 411 | 416 | open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); |
| 412 | - ret = bdrv_open3(bs, filename, open_flags, drv); | |
| 417 | + ret = drv->bdrv_open(bs, filename, open_flags); | |
| 413 | 418 | if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) { |
| 414 | - ret = bdrv_open3(bs, filename, open_flags & ~BDRV_O_RDWR, drv); | |
| 419 | + ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR); | |
| 415 | 420 | bs->read_only = 1; |
| 416 | 421 | } |
| 417 | 422 | if (ret < 0) { |
| ... | ... | @@ -456,18 +461,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
| 456 | 461 | return 0; |
| 457 | 462 | } |
| 458 | 463 | |
| 459 | -int bdrv_open3(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) | |
| 460 | -{ | |
| 461 | - char myfile[PATH_MAX]; | |
| 462 | - const char *f; | |
| 463 | - | |
| 464 | - if (!strstart(filename, "file:", &f)) { | |
| 465 | - fill_token(myfile, PATH_MAX, filename, '\0'); | |
| 466 | - return drv->bdrv_open(bs,myfile,flags); | |
| 467 | - } | |
| 468 | - return drv->bdrv_open(bs,f,flags); | |
| 469 | -} | |
| 470 | - | |
| 471 | 464 | void bdrv_close(BlockDriverState *bs) |
| 472 | 465 | { |
| 473 | 466 | if (bs->drv) { | ... | ... |
block.h
| ... | ... | @@ -57,8 +57,6 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags); |
| 57 | 57 | int bdrv_open(BlockDriverState *bs, const char *filename, int flags); |
| 58 | 58 | int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
| 59 | 59 | BlockDriver *drv); |
| 60 | -int bdrv_open3(BlockDriverState *bs, const char *filename, int flags, | |
| 61 | - BlockDriver *drv); | |
| 62 | 60 | void bdrv_close(BlockDriverState *bs); |
| 63 | 61 | int bdrv_check(BlockDriverState *bs); |
| 64 | 62 | int bdrv_read(BlockDriverState *bs, int64_t sector_num, | ... | ... |
block/dmg.c
| ... | ... | @@ -94,7 +94,7 @@ dmg_close: |
| 94 | 94 | close(s->fd); |
| 95 | 95 | /* open raw instead */ |
| 96 | 96 | bs->drv=bdrv_find_format("raw"); |
| 97 | - return bdrv_open3(bs, filename, flags, bs->drv); | |
| 97 | + return bs->drv->bdrv_open(bs, filename, flags); | |
| 98 | 98 | } |
| 99 | 99 | info_begin=read_off(s->fd); |
| 100 | 100 | if(info_begin==0) | ... | ... |
block/raw-posix.c
cutils.c
| ... | ... | @@ -24,32 +24,6 @@ |
| 24 | 24 | #include "qemu-common.h" |
| 25 | 25 | #include "host-utils.h" |
| 26 | 26 | |
| 27 | -/* | |
| 28 | - * fill first 'len' characters of 'buff' with pruned | |
| 29 | - * contents of 'str' delimited by the character 'c'. | |
| 30 | - * Escape character '\' is pruned off. | |
| 31 | - * Return pointer to the delimiting character. | |
| 32 | - */ | |
| 33 | -const char *fill_token(char *buf, const int len, const char *str, const char c) | |
| 34 | -{ | |
| 35 | - const char *p=str; | |
| 36 | - char *q=buf; | |
| 37 | - | |
| 38 | - while (p < str+len-1) { | |
| 39 | - if (*p == c) | |
| 40 | - break; | |
| 41 | - if (*p == '\\') { | |
| 42 | - p++; | |
| 43 | - if (*p == '\0') | |
| 44 | - break; | |
| 45 | - } | |
| 46 | - *q++ = *p++; | |
| 47 | - } | |
| 48 | - *q='\0'; | |
| 49 | - return p; | |
| 50 | -} | |
| 51 | - | |
| 52 | - | |
| 53 | 27 | void pstrcpy(char *buf, int buf_size, const char *str) |
| 54 | 28 | { |
| 55 | 29 | int c; | ... | ... |
qemu-common.h
| ... | ... | @@ -104,7 +104,6 @@ void qemu_get_timedate(struct tm *tm, int offset); |
| 104 | 104 | int qemu_timedate_diff(struct tm *tm); |
| 105 | 105 | |
| 106 | 106 | /* cutils.c */ |
| 107 | -const char *fill_token(char *buf, int buf_size, const char *str, char); | |
| 108 | 107 | void pstrcpy(char *buf, int buf_size, const char *str); |
| 109 | 108 | char *pstrcat(char *buf, int buf_size, const char *s); |
| 110 | 109 | int strstart(const char *str, const char *val, const char **ptr); | ... | ... |