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,7 +225,7 @@ static BlockDriver *find_protocol(const char *filename) | ||
225 | { | 225 | { |
226 | BlockDriver *drv1; | 226 | BlockDriver *drv1; |
227 | char protocol[128]; | 227 | char protocol[128]; |
228 | - int len = qemu_strnlen(filename, 127) + 1; | 228 | + int len; |
229 | const char *p; | 229 | const char *p; |
230 | 230 | ||
231 | #ifdef _WIN32 | 231 | #ifdef _WIN32 |
@@ -233,9 +233,14 @@ static BlockDriver *find_protocol(const char *filename) | @@ -233,9 +233,14 @@ static BlockDriver *find_protocol(const char *filename) | ||
233 | is_windows_drive_prefix(filename)) | 233 | is_windows_drive_prefix(filename)) |
234 | return bdrv_find_format("raw"); | 234 | return bdrv_find_format("raw"); |
235 | #endif | 235 | #endif |
236 | - p = fill_token(protocol, len, filename, ':'); | ||
237 | - if (*p != ':') | 236 | + p = strchr(filename, ':'); |
237 | + if (!p) | ||
238 | return bdrv_find_format("raw"); | 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 | for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) { | 244 | for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) { |
240 | if (drv1->protocol_name && | 245 | if (drv1->protocol_name && |
241 | !strcmp(drv1->protocol_name, protocol)) | 246 | !strcmp(drv1->protocol_name, protocol)) |
@@ -409,9 +414,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | @@ -409,9 +414,9 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | ||
409 | open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); | 414 | open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); |
410 | else | 415 | else |
411 | open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); | 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 | if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) { | 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 | bs->read_only = 1; | 420 | bs->read_only = 1; |
416 | } | 421 | } |
417 | if (ret < 0) { | 422 | if (ret < 0) { |
@@ -456,18 +461,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | @@ -456,18 +461,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | ||
456 | return 0; | 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 | void bdrv_close(BlockDriverState *bs) | 464 | void bdrv_close(BlockDriverState *bs) |
472 | { | 465 | { |
473 | if (bs->drv) { | 466 | if (bs->drv) { |
block.h
@@ -57,8 +57,6 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags); | @@ -57,8 +57,6 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags); | ||
57 | int bdrv_open(BlockDriverState *bs, const char *filename, int flags); | 57 | int bdrv_open(BlockDriverState *bs, const char *filename, int flags); |
58 | int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, | 58 | int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
59 | BlockDriver *drv); | 59 | BlockDriver *drv); |
60 | -int bdrv_open3(BlockDriverState *bs, const char *filename, int flags, | ||
61 | - BlockDriver *drv); | ||
62 | void bdrv_close(BlockDriverState *bs); | 60 | void bdrv_close(BlockDriverState *bs); |
63 | int bdrv_check(BlockDriverState *bs); | 61 | int bdrv_check(BlockDriverState *bs); |
64 | int bdrv_read(BlockDriverState *bs, int64_t sector_num, | 62 | int bdrv_read(BlockDriverState *bs, int64_t sector_num, |
block/dmg.c
@@ -94,7 +94,7 @@ dmg_close: | @@ -94,7 +94,7 @@ dmg_close: | ||
94 | close(s->fd); | 94 | close(s->fd); |
95 | /* open raw instead */ | 95 | /* open raw instead */ |
96 | bs->drv=bdrv_find_format("raw"); | 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 | info_begin=read_off(s->fd); | 99 | info_begin=read_off(s->fd); |
100 | if(info_begin==0) | 100 | if(info_begin==0) |
block/raw-posix.c
@@ -903,7 +903,6 @@ static BlockDriver bdrv_raw = { | @@ -903,7 +903,6 @@ static BlockDriver bdrv_raw = { | ||
903 | .bdrv_getlength = raw_getlength, | 903 | .bdrv_getlength = raw_getlength, |
904 | 904 | ||
905 | .create_options = raw_create_options, | 905 | .create_options = raw_create_options, |
906 | - .protocol_name = "file", | ||
907 | }; | 906 | }; |
908 | 907 | ||
909 | /***********************************************/ | 908 | /***********************************************/ |
cutils.c
@@ -24,32 +24,6 @@ | @@ -24,32 +24,6 @@ | ||
24 | #include "qemu-common.h" | 24 | #include "qemu-common.h" |
25 | #include "host-utils.h" | 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 | void pstrcpy(char *buf, int buf_size, const char *str) | 27 | void pstrcpy(char *buf, int buf_size, const char *str) |
54 | { | 28 | { |
55 | int c; | 29 | int c; |
qemu-common.h
@@ -104,7 +104,6 @@ void qemu_get_timedate(struct tm *tm, int offset); | @@ -104,7 +104,6 @@ void qemu_get_timedate(struct tm *tm, int offset); | ||
104 | int qemu_timedate_diff(struct tm *tm); | 104 | int qemu_timedate_diff(struct tm *tm); |
105 | 105 | ||
106 | /* cutils.c */ | 106 | /* cutils.c */ |
107 | -const char *fill_token(char *buf, int buf_size, const char *str, char); | ||
108 | void pstrcpy(char *buf, int buf_size, const char *str); | 107 | void pstrcpy(char *buf, int buf_size, const char *str); |
109 | char *pstrcat(char *buf, int buf_size, const char *s); | 108 | char *pstrcat(char *buf, int buf_size, const char *s); |
110 | int strstart(const char *str, const char *val, const char **ptr); | 109 | int strstart(const char *str, const char *val, const char **ptr); |