diff options
Diffstat (limited to 'base/linux_util.cc')
-rw-r--r-- | base/linux_util.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/base/linux_util.cc b/base/linux_util.cc index a58ee99..604980b 100644 --- a/base/linux_util.cc +++ b/base/linux_util.cc @@ -2,10 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "linux_util.h" +#include "base/linux_util.h" #include <stdlib.h> +#include <vector> + +#include "base/command_line.h" +#include "base/process_util.h" + namespace base { uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) { @@ -28,4 +33,30 @@ uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) { return new_pixels; } +// We use this static string to hold the Linux distro info. If we +// crash, the crash handler code will send this in the crash dump. +std::string linux_distro = "Unknown"; + +std::string GetLinuxDistro() { + static bool checked_distro = false; + if (!checked_distro) { + std::vector<std::string> argv; + argv.push_back("lsb_release"); + argv.push_back("-d"); + std::string output; + base::GetAppOutput(CommandLine(argv), &output); + if (output.length() > 0) { + // lsb_release -d should return: Description:<tab>Distro Info + static const std::string field = "Description:\t"; + if (output.compare(0, field.length(), field) == 0) + linux_distro = output.substr(field.length()); + } + // We do this check only once per process. If it fails, there's + // little reason to believe it will work if we attempt to run + // lsb_release again. + checked_distro = true; + } + return linux_distro; +} + } // namespace base |