OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_LINUX_UTIL_H_ | 5 #ifndef BASE_LINUX_UTIL_H_ |
6 #define BASE_LINUX_UTIL_H_ | 6 #define BASE_LINUX_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 class FilePath; | 14 class FilePath; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 class EnvVarGetter; | |
19 | |
20 static const char kFindInodeSwitch[] = "--find-inode"; | 18 static const char kFindInodeSwitch[] = "--find-inode"; |
21 | 19 |
22 // Get the Linux Distro if we can, or return "Unknown", similar to | 20 // Get the Linux Distro if we can, or return "Unknown", similar to |
23 // GetWinVersion() in base/win_util.h. | 21 // GetWinVersion() in base/win_util.h. |
24 std::string GetLinuxDistro(); | 22 std::string GetLinuxDistro(); |
25 | 23 |
26 // Return the inode number for the UNIX domain socket |fd|. | 24 // Return the inode number for the UNIX domain socket |fd|. |
27 bool FileDescriptorGetInode(ino_t* inode_out, int fd); | 25 bool FileDescriptorGetInode(ino_t* inode_out, int fd); |
28 | 26 |
29 // Find the process which holds the given socket, named by inode number. If | 27 // Find the process which holds the given socket, named by inode number. If |
30 // multiple processes hold the socket, this function returns false. | 28 // multiple processes hold the socket, this function returns false. |
31 bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode); | 29 bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode); |
32 | 30 |
33 // For a given process |pid|, look through all its threads and find the first | 31 // For a given process |pid|, look through all its threads and find the first |
34 // thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches | 32 // thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches |
35 // |expected_data|, where N is the length of |expected_data|. | 33 // |expected_data|, where N is the length of |expected_data|. |
36 // Returns the thread id or -1 on error. | 34 // Returns the thread id or -1 on error. |
37 pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data); | 35 pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data); |
38 | 36 |
39 } // namespace base | 37 } // namespace base |
40 | 38 |
41 #endif // BASE_LINUX_UTIL_H_ | 39 #endif // BASE_LINUX_UTIL_H_ |
OLD | NEW |