This source file includes following definitions.
- uname
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include "opal_config.h"
20 #include "opal/win32/opal_utsname.h"
21 #include "opal/util/string_copy.h"
22
23
24
25
26
27
28
29
30
31
32
33 int uname( struct utsname *un )
34 {
35 TCHAR env_variable[] = "OS=%OS%";
36 DWORD info_buf_count;
37 OSVERSIONINFO version_info;
38 SYSTEM_INFO sys_info;
39 TCHAR info_buf[OPAL_UTSNAME_LEN];
40
41 info_buf_count = ExpandEnvironmentStrings( env_variable, info_buf, OPAL_UTSNAME_LEN);
42 if (0 == info_buf_count) {
43 snprintf( un->sysname, OPAL_UTSNAME_LEN, "Unknown" );
44 } else {
45
46 opal_string_copy( un->sysname, info_buf + 3, OPAL_UTSNAME_LEN );
47 }
48 info_buf_count = OPAL_UTSNAME_LEN;
49 if (!GetComputerName( un->nodename, &info_buf_count)) {
50 snprintf(un->nodename, OPAL_UTSNAME_LEN, "undefined");
51 }
52
53 version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
54 if (!GetVersionEx(&version_info)) {
55 snprintf(un->release, OPAL_UTSNAME_LEN, "undefined");
56 snprintf(un->version, OPAL_UTSNAME_LEN, "undefined");
57 } else {
58
59 snprintf( un->release, OPAL_UTSNAME_LEN, "%d.%d.%d",
60 version_info.dwMajorVersion,
61 version_info.dwMinorVersion,
62 version_info.dwBuildNumber);
63 snprintf( un->version, OPAL_UTSNAME_LEN, "%s", version_info.szCSDVersion );
64 }
65
66
67 GetSystemInfo(&sys_info);
68 switch( sys_info.wProcessorArchitecture ) {
69 case PROCESSOR_ARCHITECTURE_UNKNOWN:
70 snprintf( un->machine, OPAL_UTSNAME_LEN, "Unknown %d", sys_info.wProcessorLevel );
71 break;
72 case PROCESSOR_ARCHITECTURE_INTEL:
73 snprintf( un->machine, OPAL_UTSNAME_LEN, "Intel %d", sys_info.wProcessorLevel );
74 break;
75 case PROCESSOR_ARCHITECTURE_IA64:
76 snprintf( un->machine, OPAL_UTSNAME_LEN, "IA64 %d", sys_info.wProcessorLevel );
77 break;
78 case PROCESSOR_ARCHITECTURE_AMD64:
79 snprintf( un->machine, OPAL_UTSNAME_LEN, "AMD %d", sys_info.wProcessorLevel );
80 break;
81 default:
82 snprintf( un->machine, OPAL_UTSNAME_LEN, "UFO hardware %d", sys_info.wProcessorLevel );
83 break;
84 }
85
86 return 0;
87 }