# HG changeset patch # User andrew # Date 1311908477 -3600 # Node ID ee4dd447f5b94a26d9a7b07b62edf03bbf930ec1 # Parent 0856b81f0466cd2d148149d9c75ce907c4de54bd Print contents of lsb-release file. Added on 2008-03-12 by Matthias Klose. diff -r 0856b81f0466 -r ee4dd447f5b9 src/os/linux/vm/os_linux.cpp --- 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)) {