chromium/base/linux_util.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/linux_util.h"

#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <iomanip>
#include <memory>
#include <string_view>

#include "base/base_export.h"
#include "base/files/dir_reader_posix.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/strings/safe_sprintf.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"

namespace base {

namespace {

#if !BUILDFLAG(IS_CHROMEOS_ASH)
std::string GetKeyValueFromOSReleaseFile(const std::string& input,
                                         const char* key) {}

bool ReadDistroFromOSReleaseFile(const char* file) {}

// https://www.freedesktop.org/software/systemd/man/os-release.html
class DistroNameGetter {};
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

bool GetThreadsFromProcessDir(const char* dir_path, std::vector<pid_t>* tids) {}

// Account for the terminating null character.
constexpr int kDistroSize =;

}  // namespace

// 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.
char g_linux_distro[kDistroSize] ="CrOS";
#elif BUILDFLAG(IS_ANDROID)
    "Android";
#else
    "Unknown";
#endif

// This function is only supposed to be used in tests. The declaration in the
// header file is guarded by "#if defined(UNIT_TEST)" so that they can be used
// by tests but not non-test code. However, this .cc file is compiled as part
// of "base" where "UNIT_TEST" is not defined. So we need to specify
// "BASE_EXPORT" here again so that they are visible to tests.
BASE_EXPORT std::string GetKeyValueFromOSReleaseFileForTesting(
    const std::string& input,
    const char* key) {}

std::string GetLinuxDistro() {}

void SetLinuxDistro(const std::string& distro) {}

bool GetThreadsForProcess(pid_t pid, std::vector<pid_t>* tids) {}

bool GetThreadsForCurrentProcess(std::vector<pid_t>* tids) {}

pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data,
                              bool* syscall_supported) {}

pid_t FindThreadID(pid_t pid, pid_t ns_tid, bool* ns_pid_supported) {}

}  // namespace base