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; | |
15 | |
16 namespace base { | 14 namespace base { |
17 | 15 |
18 static const char kFindInodeSwitch[] = "--find-inode"; | 16 static const char kFindInodeSwitch[] = "--find-inode"; |
19 | 17 |
20 // Get the Linux Distro if we can, or return "Unknown", similar to | 18 // Get the Linux Distro if we can, or return "Unknown", similar to |
21 // GetWinVersion() in base/win_util.h. | 19 // GetWinVersion() in base/win_util.h. |
22 std::string GetLinuxDistro(); | 20 std::string GetLinuxDistro(); |
23 | 21 |
24 // Return the inode number for the UNIX domain socket |fd|. | 22 // Return the inode number for the UNIX domain socket |fd|. |
25 bool FileDescriptorGetInode(ino_t* inode_out, int fd); | 23 bool FileDescriptorGetInode(ino_t* inode_out, int fd); |
26 | 24 |
27 // Find the process which holds the given socket, named by inode number. If | 25 // Find the process which holds the given socket, named by inode number. If |
28 // multiple processes hold the socket, this function returns false. | 26 // multiple processes hold the socket, this function returns false. |
29 bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode); | 27 bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode); |
30 | 28 |
31 // For a given process |pid|, look through all its threads and find the first | 29 // For a given process |pid|, look through all its threads and find the first |
32 // thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches | 30 // thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches |
33 // |expected_data|, where N is the length of |expected_data|. | 31 // |expected_data|, where N is the length of |expected_data|. |
34 // Returns the thread id or -1 on error. | 32 // Returns the thread id or -1 on error. |
35 pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data); | 33 pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data); |
36 | 34 |
37 } // namespace base | 35 } // namespace base |
38 | 36 |
39 #endif // BASE_LINUX_UTIL_H_ | 37 #endif // BASE_LINUX_UTIL_H_ |
OLD | NEW |