mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
Merge
This commit is contained in:
commit
bc5d385d04
1 changed files with 24 additions and 14 deletions
|
@ -2013,8 +2013,8 @@ void os::print_os_info(outputStream* st) {
|
||||||
// their own specific XXX-release file as well as a redhat-release file.
|
// their own specific XXX-release file as well as a redhat-release file.
|
||||||
// Because of this the XXX-release file needs to be searched for before the
|
// Because of this the XXX-release file needs to be searched for before the
|
||||||
// redhat-release file.
|
// redhat-release file.
|
||||||
// Since Red Hat has a lsb-release file that is not very descriptive the
|
// Since Red Hat and SuSE have an lsb-release file that is not very descriptive the
|
||||||
// search for redhat-release needs to be before lsb-release.
|
// search for redhat-release / SuSE-release needs to be before lsb-release.
|
||||||
// Since the lsb-release file is the new standard it needs to be searched
|
// Since the lsb-release file is the new standard it needs to be searched
|
||||||
// before the older style release files.
|
// before the older style release files.
|
||||||
// Searching system-release (Red Hat) and os-release (other Linuxes) are a
|
// Searching system-release (Red Hat) and os-release (other Linuxes) are a
|
||||||
|
@ -2031,8 +2031,8 @@ const char* distro_files[] = {
|
||||||
"/etc/mandrake-release",
|
"/etc/mandrake-release",
|
||||||
"/etc/sun-release",
|
"/etc/sun-release",
|
||||||
"/etc/redhat-release",
|
"/etc/redhat-release",
|
||||||
"/etc/lsb-release",
|
|
||||||
"/etc/SuSE-release",
|
"/etc/SuSE-release",
|
||||||
|
"/etc/lsb-release",
|
||||||
"/etc/turbolinux-release",
|
"/etc/turbolinux-release",
|
||||||
"/etc/gentoo-release",
|
"/etc/gentoo-release",
|
||||||
"/etc/ltib-release",
|
"/etc/ltib-release",
|
||||||
|
@ -2062,14 +2062,11 @@ void os::Linux::print_distro_info(outputStream* st) {
|
||||||
st->cr();
|
st->cr();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_os_info(char* distro, size_t length, const char* file) {
|
static void parse_os_info_helper(FILE* fp, char* distro, size_t length, bool get_first_line) {
|
||||||
FILE* fp = fopen(file, "r");
|
|
||||||
if (fp != NULL) {
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
// get last line of the file.
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
while (fgets(buf, sizeof(buf), fp)) { }
|
// Edit out extra stuff in expected format
|
||||||
// Edit out extra stuff in expected ubuntu format
|
if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL || strstr(buf, "PRETTY_NAME=") != NULL) {
|
||||||
if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL) {
|
|
||||||
char* ptr = strstr(buf, "\""); // the name is in quotes
|
char* ptr = strstr(buf, "\""); // the name is in quotes
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
ptr++; // go beyond first quote
|
ptr++; // go beyond first quote
|
||||||
|
@ -2083,13 +2080,26 @@ static void parse_os_info(char* distro, size_t length, const char* file) {
|
||||||
if (nl != NULL) *nl = '\0';
|
if (nl != NULL) *nl = '\0';
|
||||||
strncpy(distro, ptr, length);
|
strncpy(distro, ptr, length);
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
// if not in expected Ubuntu format, print out whole line minus \n
|
} else if (get_first_line) {
|
||||||
char* nl = strchr(buf, '\n');
|
char* nl = strchr(buf, '\n');
|
||||||
if (nl != NULL) *nl = '\0';
|
if (nl != NULL) *nl = '\0';
|
||||||
strncpy(distro, buf, length);
|
strncpy(distro, buf, length);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// close distro file
|
}
|
||||||
|
// print last line and close
|
||||||
|
char* nl = strchr(buf, '\n');
|
||||||
|
if (nl != NULL) *nl = '\0';
|
||||||
|
strncpy(distro, buf, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void parse_os_info(char* distro, size_t length, const char* file) {
|
||||||
|
FILE* fp = fopen(file, "r");
|
||||||
|
if (fp != NULL) {
|
||||||
|
// if suse format, print out first line
|
||||||
|
bool get_first_line = (strcmp(file, "/etc/SuSE-release") == 0);
|
||||||
|
parse_os_info_helper(fp, distro, length, get_first_line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue