Commit fef3074347c02ed0c2fd9d1918402c966b909466
1 parent
bd491d6a
Escape filname printout properly, by Anthony Liguori and Julian Seward.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2263 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
39 additions
and
3 deletions
block.c
| @@ -868,9 +868,12 @@ void bdrv_info(void) | @@ -868,9 +868,12 @@ void bdrv_info(void) | ||
| 868 | term_printf(" locked=%d", bs->locked); | 868 | term_printf(" locked=%d", bs->locked); |
| 869 | } | 869 | } |
| 870 | if (bs->drv) { | 870 | if (bs->drv) { |
| 871 | - term_printf(" file=%s", bs->filename); | ||
| 872 | - if (bs->backing_file[0] != '\0') | ||
| 873 | - term_printf(" backing_file=%s", bs->backing_file); | 871 | + term_printf(" file="); |
| 872 | + term_print_filename(bs->filename); | ||
| 873 | + if (bs->backing_file[0] != '\0') { | ||
| 874 | + term_printf(" backing_file="); | ||
| 875 | + term_print_filename(bs->backing_file); | ||
| 876 | + } | ||
| 874 | term_printf(" ro=%d", bs->read_only); | 877 | term_printf(" ro=%d", bs->read_only); |
| 875 | term_printf(" drv=%s", bs->drv->format_name); | 878 | term_printf(" drv=%s", bs->drv->format_name); |
| 876 | if (bs->encrypted) | 879 | if (bs->encrypted) |
monitor.c
| @@ -106,6 +106,33 @@ void term_printf(const char *fmt, ...) | @@ -106,6 +106,33 @@ void term_printf(const char *fmt, ...) | ||
| 106 | va_end(ap); | 106 | va_end(ap); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | +void term_print_filename(const char *filename) | ||
| 110 | +{ | ||
| 111 | + int i; | ||
| 112 | + | ||
| 113 | + for (i = 0; filename[i]; i++) { | ||
| 114 | + switch (filename[i]) { | ||
| 115 | + case ' ': | ||
| 116 | + case '"': | ||
| 117 | + case '\\': | ||
| 118 | + term_printf("\\%c", filename[i]); | ||
| 119 | + break; | ||
| 120 | + case '\t': | ||
| 121 | + term_printf("\\t"); | ||
| 122 | + break; | ||
| 123 | + case '\r': | ||
| 124 | + term_printf("\\r"); | ||
| 125 | + break; | ||
| 126 | + case '\n': | ||
| 127 | + term_printf("\\n"); | ||
| 128 | + break; | ||
| 129 | + default: | ||
| 130 | + term_printf("%c", filename[i]); | ||
| 131 | + break; | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | +} | ||
| 135 | + | ||
| 109 | static int monitor_fprintf(FILE *stream, const char *fmt, ...) | 136 | static int monitor_fprintf(FILE *stream, const char *fmt, ...) |
| 110 | { | 137 | { |
| 111 | va_list ap; | 138 | va_list ap; |
qemu-img.c
| @@ -113,6 +113,11 @@ void term_printf(const char *fmt, ...) | @@ -113,6 +113,11 @@ void term_printf(const char *fmt, ...) | ||
| 113 | va_end(ap); | 113 | va_end(ap); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | +void term_print_filename(const char *filename) | ||
| 117 | +{ | ||
| 118 | + term_printf(filename); | ||
| 119 | +} | ||
| 120 | + | ||
| 116 | void __attribute__((noreturn)) error(const char *fmt, ...) | 121 | void __attribute__((noreturn)) error(const char *fmt, ...) |
| 117 | { | 122 | { |
| 118 | va_list ap; | 123 | va_list ap; |
vl.h
| @@ -1318,6 +1318,7 @@ void monitor_init(CharDriverState *hd, int show_banner); | @@ -1318,6 +1318,7 @@ void monitor_init(CharDriverState *hd, int show_banner); | ||
| 1318 | void term_puts(const char *str); | 1318 | void term_puts(const char *str); |
| 1319 | void term_vprintf(const char *fmt, va_list ap); | 1319 | void term_vprintf(const char *fmt, va_list ap); |
| 1320 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); | 1320 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); |
| 1321 | +void term_print_filename(const char *filename); | ||
| 1321 | void term_flush(void); | 1322 | void term_flush(void); |
| 1322 | void term_print_help(void); | 1323 | void term_print_help(void); |
| 1323 | void monitor_readline(const char *prompt, int is_password, | 1324 | void monitor_readline(const char *prompt, int is_password, |