Merge PR #22825 into master

* refs/pull/22825/head:
	common: FreeBSD does not have /etc/os-release

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Sage Weil 2018-07-31 20:16:46 -05:00
commit c909c0aa35
2 changed files with 13 additions and 2 deletions

View File

@ -93,6 +93,7 @@ static void file_values_parse(const map<string, string>& kvm, FILE *fp, map<stri
static bool os_release_parse(map<string, string> *m, CephContext *cct)
{
#if defined(__linux__)
static const map<string, string> kvm = {
{ "distro", "ID=" },
{ "distro_description", "PRETTY_NAME=" },
@ -109,6 +110,15 @@ static bool os_release_parse(map<string, string> *m, CephContext *cct)
file_values_parse(kvm, fp, m, cct);
fclose(fp);
#elif defined(__FreeBSD__)
struct utsname u;
int r = uname(&u);
if (!r) {
m->insert(std::make_pair("distro", u.sysname));
m->insert(std::make_pair("distro_description", u.version));
m->insert(std::make_pair("distro_version", u.release));
}
#endif
return true;
}

View File

@ -207,8 +207,8 @@ static void handle_fatal_signal(int signum)
jf.dump_string("utsname_version", u.version);
jf.dump_string("utsname_machine", u.machine);
}
// os-releaes
#if defined(__linux__)
// os-release
int in = ::open("/etc/os-release", O_RDONLY);
if (in >= 0) {
char buf[4096];
@ -231,6 +231,7 @@ static void handle_fatal_signal(int signum)
}
::close(in);
}
#endif
// assert?
if (g_assert_condition) {