258
|
1 #include "animone/fd.h"
|
|
2
|
|
3 #ifdef WIN32
|
|
4 # include "animone/fd/win32.h"
|
|
5 #endif
|
|
6
|
|
7 #ifdef LINUX
|
|
8 # include "animone/fd/proc.h"
|
|
9 #endif
|
|
10
|
|
11 #ifdef MACOSX
|
|
12 # include "animone/fd/xnu.h"
|
|
13 # include "animone/util/osx.h"
|
|
14 #endif
|
|
15
|
|
16 #ifdef LIBKVM
|
|
17 # include "animone/fd/kvm.h"
|
|
18 #endif
|
|
19
|
|
20 namespace animone::internal {
|
|
21
|
|
22 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
|
|
23 bool success = false;
|
|
24
|
|
25 #ifdef WIN32
|
|
26 success ^= win32::EnumerateOpenFiles(pids, open_file_proc);
|
|
27 #endif
|
|
28
|
|
29 #ifdef LINUX
|
|
30 success ^= proc::EnumerateOpenFiles(pids, open_file_proc);
|
|
31 #endif
|
|
32
|
|
33 #ifdef MACOSX
|
|
34 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc);
|
|
35 #endif
|
|
36
|
|
37 #ifdef LIBKVM
|
|
38 success ^= kvm::EnumerateOpenFiles(pids, open_file_proc);
|
|
39 #endif
|
|
40
|
|
41 return success;
|
|
42 }
|
|
43
|
|
44 bool EnumerateOpenProcesses(process_proc_t process_proc) {
|
|
45 bool success = false;
|
|
46
|
|
47 #ifdef WIN32
|
|
48 success ^= win32::EnumerateOpenProcesses(process_proc);
|
|
49 #endif
|
|
50
|
|
51 #ifdef LINUX
|
|
52 success ^= proc::EnumerateOpenProcesses(process_proc);
|
|
53 #endif
|
|
54
|
|
55 #ifdef MACOSX
|
|
56 success ^= xnu::EnumerateOpenProcesses(process_proc);
|
|
57 #endif
|
|
58
|
|
59 #ifdef LIBKVM
|
|
60 success ^= kvm::EnumerateOpenProcesses(process_proc);
|
|
61 #endif
|
|
62
|
|
63 return success;
|
|
64 }
|
|
65
|
|
66 bool GetProcessName(pid_t pid, std::string& name) {
|
|
67 bool success = false;
|
|
68
|
|
69 #ifdef WIN32
|
|
70 success ^= win32::GetProcessName(pid, name);
|
|
71 #endif
|
|
72
|
|
73 #ifdef LINUX
|
|
74 success ^= proc::GetProcessName(pid, name);
|
|
75 #endif
|
|
76
|
|
77 #ifdef MACOSX
|
|
78 success ^= osx::util::GetProcessName(pid, name);
|
|
79 #endif
|
|
80
|
|
81 #ifdef LIBKVM
|
|
82 success ^= kvm::GetProcessName(pid, name);
|
|
83 #endif
|
|
84
|
|
85 return success;
|
|
86 }
|
|
87
|
|
88 } // namespace animone::internal
|