[Libguestfs] [PATCH] make-fs: respect libguestfs' temporary dir

Richard W.M. Jones rjones at redhat.com
Mon Jul 28 18:08:54 UTC 2014


On Mon, Jul 28, 2014 at 07:53:19PM +0200, Pino Toscano wrote:
> Do not hardcode /tmp.
> ---
>  make-fs/make-fs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/make-fs/make-fs.c b/make-fs/make-fs.c
> index 1bec3e2..9c11fef 100644
> --- a/make-fs/make-fs.c
> +++ b/make-fs/make-fs.c
> @@ -381,8 +381,9 @@ estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn)
>    CLEANUP_FCLOSE FILE *fp = NULL;
>    char line[256];
>    size_t len;
> +  CLEANUP_FREE char *tmpdir = guestfs_get_tmpdir (g);
>  
> -  if (asprintf (&tmpfile, "/tmp/makefsXXXXXX") == -1) {
> +  if (asprintf (&tmpfile, "%s/makefsXXXXXX", tmpdir) == -1) {
>      perror ("asprintf");
>      return -1;
>    }

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list