[Libguestfs] [PATCH v3 7/8] daemon: lvm_canonical_lv_name: Return EINVAL if called with non-LV.
Richard W.M. Jones
rjones at redhat.com
Thu Sep 17 12:40:03 UTC 2020
Previously callers were unable to distinguish a regular error (like an
I/O error) from the case where you call this API on something which is
valid but not a logical volume. Set errno to a known value in this
case.
---
daemon/lvm.c | 2 +-
generator/actions_core.ml | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/daemon/lvm.c b/daemon/lvm.c
index 039240866..841dc4b6b 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -757,7 +757,7 @@ do_lvm_canonical_lv_name (const char *device)
return NULL;
if (r == 0) {
- reply_with_error ("%s: not a logical volume", device);
+ reply_with_error_errno (EINVAL, "%s: not a logical volume", device);
return NULL;
}
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 9d0c0fe76..806565b19 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -5994,7 +5994,8 @@ might find to the canonical name. For example, F</dev/mapper/VG-LV>
is converted to F</dev/VG/LV>.
This command returns an error if the C<lvname> parameter does
-not refer to a logical volume.
+not refer to a logical volume. In this case errno will be
+set to C<EINVAL>.
See also C<guestfs_is_lv>, C<guestfs_canonical_device_name>." };
--
2.27.0
More information about the Libguestfs
mailing list