Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 617597 Details for
Bug 857346
[Hyper-v]The Hyper-v Linux guest version information got via kvp deamon is not correct
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
[PATCH] Changing the way of obtaining OS informations.
0001-Changing-the-way-of-obtaining-OS-informations.patch (text/plain), 3.89 KB, created by
Tomáš Hozza
on 2012-09-26 15:03:45 UTC
(
hide
)
Description:
[PATCH] Changing the way of obtaining OS informations.
Filename:
MIME Type:
Creator:
Tomáš Hozza
Created:
2012-09-26 15:03:45 UTC
Size:
3.89 KB
patch
obsolete
>From a2dd0c95252c0d8c2a1e1b37f420d24889a90b74 Mon Sep 17 00:00:00 2001 >From: Tomas Hozza <thozza@redhat.com> >Date: Tue, 25 Sep 2012 12:49:00 +0200 >Subject: [PATCH] Changing the way of obtaining OS informations. > >Changing how the OS Minor/Major versions, OS BuildNum, OS version >are obtained. Using uname() function if possible and not relying >on /etc/redhat-release. > >Bugzilla: #857346 >--- > hv_kvp_daemon.c | 116 +++++++++++++++++++++++++++++++++++++++++++------------- > 1 file changed, 89 insertions(+), 27 deletions(-) > >diff --git a/hv_kvp_daemon.c b/hv_kvp_daemon.c >index c6bdd8e..bffb248 100644 >--- a/hv_kvp_daemon.c >+++ b/hv_kvp_daemon.c >@@ -76,8 +76,9 @@ static struct sockaddr_nl addr; > static char *os_name = ""; > static char *os_major = ""; > static char *os_minor = ""; >-static char *processor_arch; >-static char *os_build; >+static char *processor_arch = ""; >+static char *os_build = ""; >+static char *os_version = ""; > static char *lic_version; > static struct utsname uts_buf; > >@@ -423,20 +424,75 @@ static void kvp_pool_enumerate(int pool, int index, __u8 *key, int key_size, > void kvp_get_os_info(void) > { > FILE *file; >- char *p, buf[512]; >+ char *p, *p1, *tmp, buf[512]; > >- uname(&uts_buf); >- os_build = uts_buf.release; >- processor_arch = uts_buf.machine; >+ /* >+ * Get the system information. >+ */ >+ if (uname(&uts_buf) < 0) { >+ syslog(LOG_ERR, "Failed to get OSinfo using uname(): #%d (%s)", errno, strerror(errno)); >+ goto uname_fail; >+ } > > /* >- * The current windows host (win7) expects the build >- * string to be of the form: x.y.z >- * Strip additional information we may have. >+ * "utsname.release" contains: "x.y.x-rel.dist..." >+ * so parse it for information. > */ >- p = strchr(os_build, '-'); >- if (p) >- *p = '\0'; >+ p1 = uts_buf.release; >+ >+ /* parse "x" for OS Major version. */ >+ p = strchr(p1, '.'); >+ if (p) { >+ tmp = strndup(p1, p - p1); >+ if (!tmp) >+ return; >+ >+ os_major = tmp; >+ } >+ else { >+ syslog(LOG_ERR, "Failed to parse utsname.release for OS Major version"); >+ goto parse_fail; >+ } >+ >+ /* parse "y" for OS Minor version. */ >+ p1 = ++p; >+ p = strchr(p1, '.'); >+ if (p) { >+ tmp = strndup(p1, p - p1); >+ if (!tmp) >+ return; >+ >+ os_minor = tmp; >+ } >+ else { >+ syslog(LOG_ERR, "Failed to parse utsname.release for OS Minor version"); >+ goto parse_fail; >+ } >+ >+ /* parse "z" for OS BuildNum. */ >+ p1 = ++p; >+ p = strchr(p1, '-'); >+ if (p) { >+ tmp = strndup(p1, p - p1); >+ if (!tmp) >+ return; >+ >+ os_build = tmp; >+ } >+ else { >+ syslog(LOG_ERR, "Failed to parse utsname.release for OS BuildNum"); >+ goto parse_fail; >+ } >+ >+ /* Assign "x.y.z" as OS Version. */ >+ os_version = uts_buf.release; >+ *p = '\0'; >+ >+parse_fail: >+ >+ processor_arch = uts_buf.machine; >+ >+uname_fail: > > file = fopen("/etc/SuSE-release", "r"); > if (file != NULL) >@@ -466,26 +522,32 @@ kvp_osinfo_found: > goto done; > os_name = p; > >- /* second line */ >- p = fgets(buf, sizeof(buf), file); >- if (p) { >- p = strchr(buf, '\n'); >- if (p) >- *p = '\0'; >- p = strdup(buf); >- if (!p) >- goto done; >- os_major = p; >- >- /* third line */ >+ /* >+ * If we didn't get OS major/minor version information using uname(), >+ * try to obtain it from file. >+ */ >+ if (!strcmp(os_major, "") && !strcmp(os_minor, "")) { >+ /* second line */ > p = fgets(buf, sizeof(buf), file); > if (p) { > p = strchr(buf, '\n'); > if (p) > *p = '\0'; > p = strdup(buf); >- if (p) >- os_minor = p; >+ if (!p) >+ goto done; >+ os_major = p; >+ >+ /* third line */ >+ p = fgets(buf, sizeof(buf), file); >+ if (p) { >+ p = strchr(buf, '\n'); >+ if (p) >+ *p = '\0'; >+ p = strdup(buf); >+ if (p) >+ os_minor = p; >+ } > } > } > } >@@ -842,7 +904,7 @@ int main(void) > strcpy(key_name, "OSMinorVersion"); > break; > case OSVersion: >- strcpy(key_value, os_build); >+ strcpy(key_value, os_version); > strcpy(key_name, "OSVersion"); > break; > case ProcessorArchitecture: >-- >1.7.11.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 857346
:
612750
|
612751
|
617002
|
617440
| 617597 |
618384