[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH v3 8/8] lib/canonical-name.c: Hide EINVAL error from underlying API call.

On Thu, Sep 17, 2020 at 01:40:04PM +0100, Richard W.M. Jones wrote:
When guestfs_lvm_canonical_lv_name was called with a /dev/dm* or
/dev/mapper* name which was not an LV then a noisy error would be
printed.  This would typically have happened with encrypted disks, and
now happens very noticably when inspecting Windows BitLocker-
encrypted guests.

Using the modified error behaviour of this API from the previous
commit we can now hide that error in that specific case.  (Even in
this case the underlying error message still gets logged in debug
lib/canonical-name.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/canonical-name.c b/lib/canonical-name.c
index 052bbf12c..e0c7918b4 100644
--- a/lib/canonical-name.c
+++ b/lib/canonical-name.c
@@ -46,9 +46,14 @@ guestfs_impl_canonical_device_name (guestfs_h *g, const char *device)
  else if (STRPREFIX (device, "/dev/mapper/") ||
           STRPREFIX (device, "/dev/dm-")) {
-    /* XXX hide errors */
+    guestfs_push_error_handler (g, NULL, NULL);

Doesn't this hide the other error which might be important as well?  The only
one I can find it the file not existing, but it means this function might fail
without an error message if I understand it correctly.

    ret = guestfs_lvm_canonical_lv_name (g, device);
-    if (ret == NULL)
+    guestfs_pop_error_handler (g);
+    /* EINVAL is expected if the device is somelike a LUKS- or
+     * BitLocker-encrypted volume, so simply return the original
+     * name in that case.
+     */
+    if (ret == NULL && guestfs_last_errno (g) == EINVAL)
      ret = safe_strdup (g, device);

Libguestfs mailing list
Libguestfs redhat com

Attachment: signature.asc
Description: PGP signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]