Index: runtime/bin/platform_linux.cc |
diff --git a/runtime/bin/platform_linux.cc b/runtime/bin/platform_linux.cc |
index a085dff1773d4cdf9e993ce608a01fe85308671e..e681f034b89ac82a1b457fdca276d20dd009d357 100644 |
--- a/runtime/bin/platform_linux.cc |
+++ b/runtime/bin/platform_linux.cc |
@@ -7,9 +7,10 @@ |
#include "bin/platform.h" |
-#include <signal.h> // NOLINT |
-#include <string.h> // NOLINT |
-#include <unistd.h> // NOLINT |
+#include <signal.h> // NOLINT |
+#include <string.h> // NOLINT |
+#include <sys/utsname.h> // NOLINT |
+#include <unistd.h> // NOLINT |
#include "bin/fdutils.h" |
#include "bin/file.h" |
@@ -72,6 +73,28 @@ const char* Platform::OperatingSystem() { |
return "linux"; |
} |
+const char* Platform::OperatingSystemVersion() { |
+ struct utsname info; |
+ int ret = uname(&info); |
+ if (ret != 0) { |
+ return NULL; |
+ } |
+ const char* kFormat = "%s %s %s"; |
+ int len = |
+ snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version); |
+ if (len <= 0) { |
+ return NULL; |
+ } |
+ char* result = DartUtils::ScopedCString(len + 1); |
+ ASSERT(result != NULL); |
+ len = snprintf(result, len + 1, kFormat, info.sysname, info.release, |
+ info.version); |
+ if (len <= 0) { |
+ return NULL; |
+ } |
+ return result; |
+} |
+ |
const char* Platform::LibraryPrefix() { |
return "lib"; |
} |