[Libguestfs] [PATCH 4/5] inspect: fix existance check of /dev/mapper devices

Richard W.M. Jones rjones at redhat.com
Wed Dec 7 10:24:41 UTC 2016


On Tue, Dec 06, 2016 at 04:29:21PM +0100, Pino Toscano wrote:
> @@ -1820,7 +1833,7 @@ resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table *md_map,
>    char *type, *slice, *disk, *part;
>    int r;
>  
> -  if (STRPREFIX (spec, "/dev/mapper/") && guestfs_exists (g, spec) > 0) {
> +  if (STRPREFIX (spec, "/dev/mapper/") && dev_mapper_exists (g, spec) > 0) {
...
    device = guestfs_lvm_canonical_lv_name (g, spec);
  }


I think really the problem is with the call to
guestfs_lvm_canonical_lv_name.

Can we not replace this code with:

if (STRPREFIX (spec, "/dev/mapper/")) {
...
  guestfs_push_error_handler (g, NULL, NULL);
  device = guestfs_lvm_canonical_lv_name (g, spec);
  guestfs_pop_error_handler (g);
  if (device == NULL) {
    if (guestfs_last_errno (g) == ENOENT)
      // ignore error
    else {
      guestfs_int_error_errno (/* copy the handle error message & errno here */);
      return -1;
  }
}

?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list