[Spice-devel] [PATCH spice-server] Attempt to create bitmap debug directory

Christophe Fergeau cfergeau at redhat.com
Fri Apr 7 14:38:39 UTC 2017


On Fri, Mar 24, 2017 at 12:11:28PM +0000, Frediano Ziglio wrote:
> The DUMP_BITMAP compile option enable some debugging code to
> output image bitmaps in a subdirectory of /tmp.
> However if this directory does not exists the server will crash
> as not able to create a file in it.
> Try to create directory before creating the file.

Acked-by: Christophe Fergeau <cfergeau at redhat.com>

Not that creating files in /tmp usually requires special care, so good
that this code is not enabled by default, and only a debugging tool.
Fwiw, I'd change #define RAM_PATH "/tmp/tmpfs" to some better named
path (/tmp/spice-bitmap-dumps ?)

Christophe


> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/spice-bitmap-utils.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/server/spice-bitmap-utils.c b/server/spice-bitmap-utils.c
> index 439f05d..09c081d 100644
> --- a/server/spice-bitmap-utils.c
> +++ b/server/spice-bitmap-utils.c
> @@ -18,6 +18,9 @@
>  #ifdef HAVE_CONFIG_H
>  #include <config.h>
>  #endif
> +
> +#include <sys/stat.h>
> +
>  #include "spice-bitmap-utils.h"
>  
>  #define RED_BITMAP_UTILS_RGB16
> @@ -252,6 +255,7 @@ void dump_bitmap(SpiceBitmap *bitmap)
>      file_size = bitmap_data_offset + (bitmap->y * row_size);
>  
>      id = ++file_id;
> +    mkdir(RAM_PATH, 0755);
>      sprintf(file_str, "%s/%u.bmp", RAM_PATH, id);
>  
>      f = fopen(file_str, "wb");
> -- 
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170407/df8f69b8/attachment-0001.sig>


More information about the Spice-devel mailing list