]> git.sven.stormbind.net Git - sven/jattach.git/blob - src/posix/psutil.h
releasing package jattach version 2.2-1
[sven/jattach.git] / src / posix / psutil.h
1 /*
2  * Copyright jattach authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef _PSUTIL_H
18 #define _PSUTIL_H
19
20 #include <sys/types.h>
21
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define MAX_PATH 1024
28 extern char tmp_path[];
29
30 // Gets /tmp path of the specified process, as it can be accessed from the host.
31 // The obtained path is stored in the global tmp_path buffer.
32 void get_tmp_path(int pid);
33
34 // The reentrant version of get_tmp_path.
35 // Stores the process-specific temporary path into the provided buffer.
36 // Returns 0 on success, -1 on failure.
37 int get_tmp_path_r(int pid, char* buf, size_t bufsize);
38
39 // Gets the owner uid/gid of the target process, and also its pid inside the container.
40 // Returns 0 on success, -1 on failure.
41 int get_process_info(int pid, uid_t* uid, gid_t* gid, int* nspid);
42
43 // Tries to enter the namespace of the target process.
44 // type of the namespace can be "mnt", "net", "pid", etc.
45 // Returns 1, if the namespace has been successfully changed,
46 //         0, if the target process is in the same namespace as the host,
47 //        -1, if the attempt failed.
48 int enter_ns(int pid, const char* type);
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54 #endif // _PSUTIL_H