From d297b9a86f6345d7ceb1c986e6f5c41e34af04b2 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Sat, 31 Mar 2018 04:50:31 +0300 Subject: [PATCH] Add hostinfo wsl fields Signed-off-by: Vitalii Koshura --- lib/hostinfo.cpp | 23 ++++++++++++++++++++++- lib/hostinfo.h | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/hostinfo.cpp b/lib/hostinfo.cpp index 475fd7048e..3414f65db8 100644 --- a/lib/hostinfo.cpp +++ b/lib/hostinfo.cpp @@ -69,6 +69,11 @@ void HOST_INFO::clear_host_info() { safe_strcpy(os_name, ""); safe_strcpy(os_version, ""); + + os_wsl_enabled = false; + safe_strcpy(os_wsl_name, ""); + safe_strcpy(os_wsl_version, ""); + safe_strcpy(product_name, ""); safe_strcpy(mac_address, ""); @@ -124,6 +129,9 @@ int HOST_INFO::parse(XML_PARSER& xp, bool static_items_only) { if (xp.parse_double("d_free", d_free)) continue; if (xp.parse_str("os_name", os_name, sizeof(os_name))) continue; if (xp.parse_str("os_version", os_version, sizeof(os_version))) continue; + if (xp.parse_bool("os_wsl_enabled", os_wsl_enabled)) continue; + if (xp.parse_str("os_wsl_name", os_wsl_name, sizeof(os_wsl_name))) continue; + if (xp.parse_str("os_wsl_version", os_wsl_version, sizeof(os_wsl_version))) continue; if (xp.parse_str("product_name", product_name, sizeof(product_name))) continue; if (xp.parse_str("virtualbox_version", virtualbox_version, sizeof(virtualbox_version))) continue; if (xp.match_tag("coprocs")) { @@ -154,7 +162,7 @@ int HOST_INFO::parse(XML_PARSER& xp, bool static_items_only) { int HOST_INFO::write( MIOFILE& out, bool include_net_info, bool include_coprocs ) { - char pv[265], pm[256], pf[1024], osn[256], osv[256], pn[256]; + char pv[265], pm[256], pf[1024], osn[256], osv[256], oswsln[256], oswslv[256], pn[256]; out.printf( "\n" " %d\n", @@ -173,6 +181,8 @@ int HOST_INFO::write( xml_escape(p_features, pf, sizeof(pf)); xml_escape(os_name, osn, sizeof(osn)); xml_escape(os_version, osv, sizeof(osv)); + xml_escape(os_wsl_name, oswsln, sizeof(oswsln)); + xml_escape(os_wsl_version, oswslv, sizeof(oswslv)); out.printf( " %s\n" " %d\n" @@ -211,6 +221,17 @@ int HOST_INFO::write( osv, coprocs.ndevs() ); + if (os_wsl_enabled) { + out.printf( + " %d\n" + " %s\n" + " %s\n" + , + os_wsl_enabled, + oswsln, + oswslv + ); + } if (strlen(product_name)) { xml_escape(product_name, pn, sizeof(pn)); out.printf( diff --git a/lib/hostinfo.h b/lib/hostinfo.h index e18e265583..051c3ca090 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -61,6 +61,12 @@ public: char os_name[256]; char os_version[256]; + + // WSL information for Win10 only + bool os_wsl_enabled; + char os_wsl_name[256]; + char os_wsl_version[256]; + char product_name[256]; // manufacturer and/or model of system char mac_address[256]; // MAC addr e.g. 00:00:00:00:00:00 // currently populated for Android