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
This commit is contained in:
parent
bd491d6a4e
commit
fef3074347
9
block.c
9
block.c
@ -868,9 +868,12 @@ void bdrv_info(void)
|
|||||||
term_printf(" locked=%d", bs->locked);
|
term_printf(" locked=%d", bs->locked);
|
||||||
}
|
}
|
||||||
if (bs->drv) {
|
if (bs->drv) {
|
||||||
term_printf(" file=%s", bs->filename);
|
term_printf(" file=");
|
||||||
if (bs->backing_file[0] != '\0')
|
term_print_filename(bs->filename);
|
||||||
term_printf(" backing_file=%s", bs->backing_file);
|
if (bs->backing_file[0] != '\0') {
|
||||||
|
term_printf(" backing_file=");
|
||||||
|
term_print_filename(bs->backing_file);
|
||||||
|
}
|
||||||
term_printf(" ro=%d", bs->read_only);
|
term_printf(" ro=%d", bs->read_only);
|
||||||
term_printf(" drv=%s", bs->drv->format_name);
|
term_printf(" drv=%s", bs->drv->format_name);
|
||||||
if (bs->encrypted)
|
if (bs->encrypted)
|
||||||
|
27
monitor.c
27
monitor.c
@ -106,6 +106,33 @@ void term_printf(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void term_print_filename(const char *filename)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; filename[i]; i++) {
|
||||||
|
switch (filename[i]) {
|
||||||
|
case ' ':
|
||||||
|
case '"':
|
||||||
|
case '\\':
|
||||||
|
term_printf("\\%c", filename[i]);
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
term_printf("\\t");
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
term_printf("\\r");
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
term_printf("\\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
term_printf("%c", filename[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int monitor_fprintf(FILE *stream, const char *fmt, ...)
|
static int monitor_fprintf(FILE *stream, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -113,6 +113,11 @@ void term_printf(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void term_print_filename(const char *filename)
|
||||||
|
{
|
||||||
|
term_printf(filename);
|
||||||
|
}
|
||||||
|
|
||||||
void __attribute__((noreturn)) error(const char *fmt, ...)
|
void __attribute__((noreturn)) error(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
1
vl.h
1
vl.h
@ -1318,6 +1318,7 @@ void monitor_init(CharDriverState *hd, int show_banner);
|
|||||||
void term_puts(const char *str);
|
void term_puts(const char *str);
|
||||||
void term_vprintf(const char *fmt, va_list ap);
|
void term_vprintf(const char *fmt, va_list ap);
|
||||||
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
|
void term_print_filename(const char *filename);
|
||||||
void term_flush(void);
|
void term_flush(void);
|
||||||
void term_print_help(void);
|
void term_print_help(void);
|
||||||
void monitor_readline(const char *prompt, int is_password,
|
void monitor_readline(const char *prompt, int is_password,
|
||||||
|
Loading…
Reference in New Issue
Block a user