blob: 4f2808b93f5188d4318663fa6a78bb4dfac1e927 [file] [log] [blame]
[email protected]68a008e82011-05-02 17:54:141// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]75ae5422009-04-21 17:20:102// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]9bc8cff2010-04-03 01:05:395#ifndef BASE_LINUX_UTIL_H_
6#define BASE_LINUX_UTIL_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]75ae5422009-04-21 17:20:108
9#include <stdint.h>
[email protected]b28af7522009-10-29 18:21:3010#include <sys/types.h>
[email protected]75ae5422009-04-21 17:20:1011
[email protected]912c6452009-07-17 05:55:5112#include <string>
13
[email protected]0bea7252011-08-05 15:34:0014#include "base/base_export.h"
[email protected]68a008e82011-05-02 17:54:1415
[email protected]75ae5422009-04-21 17:20:1016namespace base {
17
[email protected]8ecd3aad2009-11-04 08:32:2218static const char kFindInodeSwitch[] = "--find-inode";
19
[email protected]6dde9d72010-08-26 08:55:2220// This is declared here so the crash reporter can access the memory directly
21// in compromised context without going through the standard library.
[email protected]0bea7252011-08-05 15:34:0022BASE_EXPORT extern char g_linux_distro[];
[email protected]6dde9d72010-08-26 08:55:2223
[email protected]a8e20582010-12-31 17:18:5024// Get the Linux Distro if we can, or return "Unknown".
[email protected]0bea7252011-08-05 15:34:0025BASE_EXPORT std::string GetLinuxDistro();
[email protected]912c6452009-07-17 05:55:5126
[email protected]6dde9d72010-08-26 08:55:2227// Set the Linux Distro string.
[email protected]0bea7252011-08-05 15:34:0028BASE_EXPORT void SetLinuxDistro(const std::string& distro);
[email protected]6dde9d72010-08-26 08:55:2229
[email protected]85ebe8f2009-10-29 04:02:5530// Return the inode number for the UNIX domain socket |fd|.
[email protected]0bea7252011-08-05 15:34:0031BASE_EXPORT bool FileDescriptorGetInode(ino_t* inode_out, int fd);
[email protected]85ebe8f2009-10-29 04:02:5532
33// Find the process which holds the given socket, named by inode number. If
34// multiple processes hold the socket, this function returns false.
[email protected]0bea7252011-08-05 15:34:0035BASE_EXPORT bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode);
[email protected]85ebe8f2009-10-29 04:02:5536
[email protected]662183142010-07-16 19:28:1737// For a given process |pid|, look through all its threads and find the first
38// thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches
39// |expected_data|, where N is the length of |expected_data|.
[email protected]cb7d53e2011-06-21 04:21:0640// Returns the thread id or -1 on error. If |syscall_supported| is
41// set to false the kernel does not support syscall in procfs.
[email protected]0bea7252011-08-05 15:34:0042BASE_EXPORT pid_t FindThreadIDWithSyscall(pid_t pid,
43 const std::string& expected_data,
44 bool* syscall_supported);
[email protected]662183142010-07-16 19:28:1745
[email protected]75ae5422009-04-21 17:20:1046} // namespace base
47
[email protected]9bc8cff2010-04-03 01:05:3948#endif // BASE_LINUX_UTIL_H_