[Libguestfs] [PATCH] inspect: avoid returning "unknownX.Y" for unknown Linux distros

Pino Toscano ptoscano at redhat.com
Wed Jan 8 17:39:47 UTC 2020


If it is not possible to detect the distribution of a Linux OS, do not
propose "unknownX.Y" (where X is the major version number, and Y the
minor) as short osinfo ID. Just return "unknown" instead.
---
 lib/inspect-osinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c
index ba07e4564..d2272dfdd 100644
--- a/lib/inspect-osinfo.c
+++ b/lib/inspect-osinfo.c
@@ -70,7 +70,7 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root)
       return safe_asprintf (g, "%s%d.%d", distro, major, minor);
     }
 
-    if (major > 0 || minor > 0)
+    if (STRNEQ (distro, "unknown") && (major > 0 || minor > 0))
       return safe_asprintf (g, "%s%d.%d", distro, major, minor);
   }
   else if (STREQ (type, "freebsd") || STREQ (type, "netbsd") || STREQ (type, "openbsd"))
-- 
2.24.1




More information about the Libguestfs mailing list