Load procfs on booting time
[platform/core/connectivity/stc-manager.git] / src / helper / helper-procfs.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
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
18 #ifndef __HELPER_PROCFS_H__
19 #define __HELPER_PROCFS_H__
20
21 #include <stdio.h>
22
23 #define PROC_BUF_MAX 64
24
25 typedef bool (*proc_pid_cb)(pid_t pid, void *user_data);
26
27 /**
28  * @desc get command line from /proc/{pid}/cmdline
29  * @return negative value if error
30  */
31 int proc_get_cmdline(pid_t pid, char *cmdline);
32
33 /**
34  * @desc find pid with /proc/{pid}/cmdline
35  * it returns first entry when many pids have same cmdline
36  * @return negative value if error
37  */
38 pid_t find_pid_from_cmdline(char *cmdline);
39
40 /**
41  * @desc find pid from /proc
42  */
43 void proc_foreach_pid(proc_pid_cb cb, void *user_data);
44
45 /**
46  * @desc get smack subject label from /proc/{pid}/attr/current
47  * this label can indicate package name about child processes
48  * @return negative value if error or pid doesn't exist
49  */
50 int proc_get_label(pid_t pid, char *label);
51
52 /**
53  * @desc get command line from /proc/{pid}/cmdline without any truncation
54  * @return negative value if error
55  */
56 int proc_get_raw_cmdline(pid_t pid, char *buf, int len);
57
58 /**
59  * @desc get symblolic link about /proc/{pid}/exe
60  * @return negative value if error
61  */
62 int proc_get_exepath(pid_t pid, char *buf, int len);
63
64 /**
65  * @desc get status from /proc/{pid}/status
66  * @return negative value if error
67  */
68 int proc_get_status(pid_t pid, char status[][PROC_BUF_MAX]);
69
70 #endif /*__HELPER_PROCFS_H__*/