Patchwork [4/5] console: switch ppm_save to qemu_open

login
register
mail settings
Submitter Gerd Hoffmann
Date April 24, 2013, 9:33 a.m.
Message ID <1366796002-30135-5-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/239097/
State New
Headers show

Comments

Gerd Hoffmann - April 24, 2013, 9:33 a.m.
... so it works with fdset.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/console.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch

diff --git a/ui/console.c b/ui/console.c
index e3ab985..3835316 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -269,18 +269,20 @@  static void ppm_save(const char *filename, struct DisplaySurface *ds,
 {
     int width = pixman_image_get_width(ds->image);
     int height = pixman_image_get_height(ds->image);
+    int fd;
     FILE *f;
     int y;
     int ret;
     pixman_image_t *linebuf;
 
     trace_ppm_save(filename, ds);
-    f = fopen(filename, "wb");
-    if (!f) {
+    fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+    if (fd == -1) {
         error_setg(errp, "failed to open file '%s': %s", filename,
                    strerror(errno));
         return;
     }
+    f = fdopen(fd, "wb");
     ret = fprintf(f, "P6\n%d %d\n%d\n", width, height, 255);
     if (ret < 0) {
         linebuf = NULL;