This is an update of my previous patch of the same name. It includes a fix for filename's containing backslashes that was caught by Julian Seward.

Regards,

Anthony Liguori
diff -r 7d5869c61e0d block.c
--- a/block.c	Sat Dec 16 11:50:51 2006 -0600
+++ b/block.c	Sat Dec 16 14:34:22 2006 -0600
@@ -868,9 +868,12 @@ void bdrv_info(void)
             term_printf(" locked=%d", bs->locked);
         }
         if (bs->drv) {
-            term_printf(" file=%s", bs->filename);
-            if (bs->backing_file[0] != '\0')
-                term_printf(" backing_file=%s", bs->backing_file);
+            term_printf(" file=");
+	    term_print_filename(bs->filename);
+            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(" drv=%s", bs->drv->format_name);
             if (bs->encrypted)
diff -r 7d5869c61e0d monitor.c
--- a/monitor.c	Sat Dec 16 11:50:51 2006 -0600
+++ b/monitor.c	Sun Dec 17 10:33:59 2006 -0600
@@ -104,6 +104,33 @@ void term_printf(const char *fmt, ...)
     va_start(ap, fmt);
     term_vprintf(fmt, 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, ...)
diff -r 7d5869c61e0d qemu-img.c
--- a/qemu-img.c	Sat Dec 16 11:50:51 2006 -0600
+++ b/qemu-img.c	Sat Dec 16 14:34:22 2006 -0600
@@ -111,6 +111,11 @@ void term_printf(const char *fmt, ...)
     va_start(ap, fmt);
     vprintf(fmt, ap);
     va_end(ap);
+}
+
+void term_print_filename(const char *filename)
+{
+    term_printf(filename);
 }
 
 void __attribute__((noreturn)) error(const char *fmt, ...) 
diff -r 7d5869c61e0d vl.h
--- a/vl.h	Sat Dec 16 11:50:51 2006 -0600
+++ b/vl.h	Sun Dec 17 10:33:36 2006 -0600
@@ -1318,6 +1318,7 @@ void term_puts(const char *str);
 void term_puts(const char *str);
 void term_vprintf(const char *fmt, va_list ap);
 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
+void term_print_filename(const char *filename);
 void term_flush(void);
 void term_print_help(void);
 void monitor_readline(const char *prompt, int is_password,
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to