Pino Toscano
2020-Jan-08 17:39 UTC
[Libguestfs] [PATCH] inspect: avoid returning "unknownX.Y" for unknown Linux distros
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
Richard W.M. Jones
2020-Jan-09 13:19 UTC
Re: [Libguestfs] [PATCH] inspect: avoid returning "unknownX.Y" for unknown Linux distros
On Wed, Jan 08, 2020 at 06:39:47PM +0100, Pino Toscano wrote:> 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")) > --ACK 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
Seemingly Similar Threads
- [PATCH] inspect: correct osinfo ID for CentOS >= 8
- [PATCH] inspect: return osinfo short IDs for recent Windows versions
- [PATCH v2] inspect: return osinfo short IDs for recent Windows versions
- [PATCH 0/5] Small inspection improvements
- [PATCH 5/5] inspect: correct osinfo ID for ALT Linux >= 8