[Libguestfs] [PATCH v2 3/3] fish: fix btrfs subvolumes display in error case

Pino Toscano ptoscano at redhat.com
Tue Mar 8 14:04:04 UTC 2016


On Tuesday 08 March 2016 10:26:59 Cédric Bosdonnat wrote:
> The list of filesystems that is printed when there was an error prints
> the internal mountable string even for the btrfs subvolumes. Let's
> printing a valid -m option value instead.
> ---
>  fish/options.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/fish/options.c b/fish/options.c
> index da5015d..9222b69 100644
> --- a/fish/options.c
> +++ b/fish/options.c
> @@ -280,7 +280,33 @@ display_mountpoints_on_failure (const char *mp_device,
>             guestfs_int_program_name);
>  
>    for (i = 0; fses[i] != NULL; i += 2) {
> -    CLEANUP_FREE char *p = guestfs_canonical_device_name (g, fses[i]);
> +    CLEANUP_FREE char *p = NULL;
> +    CLEANUP_FREE char *device = guestfs_mountable_device(g, fses[i]);

Same small coding style issues (missing space before round bracket,
indentation) also in few lines of this patch.

> +    CLEANUP_FREE char *subvolume = NULL;
> +    int subvolume_errno;

This variable looks unused.

> +
> +    guestfs_push_error_handler (g, NULL, NULL);
> +
> +    subvolume = guestfs_mountable_subvolume(g, fses[i]);
> +    if (subvolume == NULL && guestfs_last_errno (g) != EINVAL) {
> +      fprintf (stderr,
> +               _("%s: cannot determine the subvolume for %s: %s (%d)\n"),
> +              guestfs_int_program_name, fses[i],
> +              guestfs_last_error (g), guestfs_last_errno (g));

Most probably exit (EXIT_FAILURE) is needed here, as it represents a
failure.

> +    }
> +
> +    guestfs_pop_error_handler (g);
> +
> +    /* Reformat the internal btrfsvol string into a valid mount option */
> +    if (device && subvolume) {
> +      if (asprintf (&p, "%s:/:subvol=%s", device, subvolume) == -1) {
> +          perror ("asprintf");
> +          exit (EXIT_FAILURE);
> +      }
> +    } else {
> +      p = guestfs_canonical_device_name (g, fses[i]);
> +    }
> +
>      fprintf (stderr, "%s: \t%s (%s)\n", guestfs_int_program_name,
>               p ? p : fses[i], fses[i+1]);
>    }

Otherwise, the patch seems fine for me.

Thanks,
-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20160308/953fa5a4/attachment.sig>


More information about the Libguestfs mailing list