changeset 2646:ee4dd447f5b9

Print contents of lsb-release file. Added on 2008-03-12 by Matthias Klose.
author andrew
date Fri, 29 Jul 2011 04:01:17 +0100
parents 0856b81f0466
children 2abb145bee7e
files src/os/linux/vm/os_linux.cpp
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/linux/vm/os_linux.cpp	Fri Jul 29 03:59:50 2011 +0100
+++ b/src/os/linux/vm/os_linux.cpp	Fri Jul 29 04:01:17 2011 +0100
@@ -1982,6 +1982,37 @@
   return true;
 }
 
+bool _print_lsb_file(const char* filename, outputStream* st) {
+  int fd = open(filename, O_RDONLY);
+  if (fd == -1) {
+     return false;
+  }
+
+  char buf[512], *d_i, *d_r, *d_c;
+  int bytes;
+
+  if ((bytes = read(fd, buf, sizeof(buf)-1)) == sizeof(buf)-1) {
+     close(fd);
+     return false;
+  }
+  close(fd);
+
+  buf[bytes] = '\n';
+  buf[bytes+1] = '\0';
+  d_i = strstr(buf, "DISTRIB_ID=");
+  d_r = strstr(buf, "DISTRIB_RELEASE=");
+  d_c = strstr(buf, "DISTRIB_CODENAME=");
+  if (!d_i || !d_r || !d_c) {
+     return false;
+  }
+  d_i = strchr(d_i, '=') + 1;  *strchrnul(d_i, '\n') = '\0';
+  d_r = strchr(d_r, '=') + 1;  *strchrnul(d_r, '\n') = '\0';
+  d_c = strchr(d_c, '=') + 1;  *strchrnul(d_c, '\n') = '\0';
+  st->print("%s %s (%s)", d_i, d_r, d_c);
+
+  return true;
+}
+
 void os::print_dll_info(outputStream *st) {
    st->print_cr("Dynamic libraries:");
 
@@ -2010,6 +2041,7 @@
       !_print_ascii_file("/etc/SuSE-release", st) &&
       !_print_ascii_file("/etc/turbolinux-release", st) &&
       !_print_ascii_file("/etc/gentoo-release", st) &&
+      !_print_lsb_file("/etc/lsb-release", st) &&
       !_print_ascii_file("/etc/debian_version", st) &&
       !_print_ascii_file("/etc/ltib-release", st) &&
       !_print_ascii_file("/etc/angstrom-version", st)) {