2 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __HELPER_PROCFS_H__
19 #define __HELPER_PROCFS_H__
23 #define PROC_BUF_MAX 64
25 typedef bool (*proc_pid_cb)(pid_t pid, void *user_data);
28 * @desc get command line from /proc/{pid}/cmdline
29 * @return negative value if error
31 int proc_get_cmdline(pid_t pid, char *cmdline);
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
38 pid_t find_pid_from_cmdline(char *cmdline);
41 * @desc find pid from /proc
43 void proc_foreach_pid(proc_pid_cb cb, void *user_data);
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
50 int proc_get_label(pid_t pid, char *label);
53 * @desc get command line from /proc/{pid}/cmdline without any truncation
54 * @return negative value if error
56 int proc_get_raw_cmdline(pid_t pid, char *buf, int len);
59 * @desc get symblolic link about /proc/{pid}/exe
60 * @return negative value if error
62 int proc_get_exepath(pid_t pid, char *buf, int len);
65 * @desc get status from /proc/{pid}/status
66 * @return negative value if error
68 int proc_get_status(pid_t pid, char status[][PROC_BUF_MAX]);
70 #endif /*__HELPER_PROCFS_H__*/