Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

AIX - os.release() returns only minor version of OS #34

Closed
andrewlow opened this issue May 30, 2014 · 2 comments
Closed

AIX - os.release() returns only minor version of OS #34

andrewlow opened this issue May 30, 2014 · 2 comments
Assignees

Comments

@andrewlow
Copy link
Collaborator

os.release(); will return '1' on AIX 6.1

On Linux systems we get back the same answer as uname -r

The documentation http://nodejs.org/api/os.html#os_os_release claims to run the operating system release. (it appears to be open to interpretation)

@andrewlow
Copy link
Collaborator Author

On AIX - uname -rv returns "1 6"
This is interpreted as release 1, version 6 -> humans would call this 6.1

The following patch causes os.release() on AIX to return just that

diff --git a/src/node_os.cc b/src/node_os.cc
index 07f73f4..571cc91 100644
--- a/src/node_os.cc
+++ b/src/node_os.cc
@@ -94,7 +94,19 @@ static Handle<Value> GetOSRelease(const Arguments& args) {
   if (uname(&info) < 0) {
     return ThrowException(ErrnoException(errno, "uname"));
   }
+#ifdef _AIX
+  /*
+   * On AIX info.release is only a part of OS release version.
+   * We need to combine info.version and info.release
+   */
+  char versionInfo[2*SYS_NMLN+1] = {0};
+  strcpy(versionInfo, info.version);
+  versionInfo[strlen(info.version)] = '.';
+  strcpy(versionInfo + strlen(info.version) + 1, info.release);
+  return scope.Close(String::New(versionInfo));
+#else
   return scope.Close(String::New(info.release));
+#endif
 #else // __MINGW32__
   char release[256];
   OSVERSIONINFO info;

@jBarz
Copy link

jBarz commented Dec 13, 2016

nodejs/node#10245

@jBarz jBarz self-assigned this Dec 13, 2016
@jBarz jBarz closed this as completed Dec 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants