1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*
* libslp-sysman
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: DongGi Jang <dg0402.jang@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef ___SYSMAN___
#define ___SYSMAN___
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include "sysman_managed.h"
#ifndef DEPRECATED
#define DEPRECATED __attribute__((deprecated))
#endif
/**
* @file sysman.h
* @ingroup libsysman System Manager library
* @brief This library provides APIs related with memory, performance, processes, and so on.
* @author SLP2.0
* @date 2010-01-24
* @version 0.1
*/
/**
* @defgroup libsysman System Manager library
* @ingroup SYSTEM_FRAMEWORK
* @brief System manager library
*
* This library provides APIs related with memory, performance, processes, and so on.
* <br> Please use libslp-sysman-dev debian package and sysman.pc file for development.
* <br> And include sysman.h file at your source codes as following.
* @addtogroup libsysman System Manager library
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @breif Policy for low memory
*/
enum mem_policy {
OOM_LIKELY, /**< For miscellaneous applications */
OOM_IGNORE /**< For daemons */
};
/* sysman_util */
/**
* @fn int sysman_get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
* @brief This API is used to get the file name of command line of the process from the proc fs.
* Caller process MUST allocate enough memory for the cmdline parameter. \n
* Its size should be assigned to cmdline_size. \n
* Internally it reads the 1st argument of /proc/{pid}/cmdline and copies it to cmdline.
* @param[in] pid pid of the process that you want to get the file name of command line
* @param[out] cmdline command line of the process that you want to get the file name <br>
* Callers should allocate memory to this parameter before calling this function.
* The allocated memory size must be large enough to store the file name.
* The result will include the terminating null byte('\0') at the end of the string.
* @return 0 on success, -1 if failed. If the size of cmdline is smaller than the result,
* it will return -1 and errno will be set as EOVERFLOW.
*/
int sysman_get_cmdline_name(pid_t pid, char *cmdline,
size_t cmdline_size);
/**
* @fn char *sysman_get_apppath(pid_t pid, char *app_path, size_t app_path_size)
* @brief This API is used to get the execution path of the process specified by the pid parameter.\n
* Caller process MUST allocate enough memory for the app_path parameter. \n
* Its size should be assigned to app_path_size. \n
* Internally it reads a link of /proc/{pid}/exe and copies the path to app_path.
* @param[in] pid pid of the process that you want to get the executed path
* @param[out] app_path the executed file path of the process <br>
* Callers should allocate memory to this parameter before calling this function.
* The allocated memory size must be large enough to store the executed file path.
* The result will include the terminating null byte('\0') at the end of the string.
* @param[in] app_path_size allocated memory size of char *app_path
* @return 0 on success, -1 if failed. If the size of app_path is smaller than the result,
* it will return -1 and errno will be set as EOVERFLOW.
*/
int sysman_get_apppath(pid_t pid, char *app_path, size_t app_path_size);
/* sysconf */
/**
* @fn int sysconf_set_mempolicy(enum mem_policy mempol)
* @brief This API is used to set the policy of the caller process when the phone has low available memory.
* @param[in] mempol oom adjust value which you want to set
* @return 0 on success, -1 if failed.
* @see sysconf_set_mempolicy_bypid()
*/
int sysconf_set_mempolicy(enum mem_policy mempol);
/**
* @fn int sysconf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol)
* @brief This API is used to set the policy of the process when the phone has low available memory.
* @param[in] pid process id which you want to set
* @param[in] mempol oom adjust value which you want to set
* @return 0 on success, -1 if failed.
*/
int sysconf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol);
/**
* @fn int sysconf_set_permanent(void)
* @brief This API is used to set itself as a permanent process.\n
* If the permanent process is dead, system server will relaunch the process automatically.
* @return 0 on success, -1 if failed.
* @see sysconf_set_permanent_bypid()
* @par Example
* @code
* ...
* ret = sysconf_set_permanent();
* if( ret < 0 )
* printf("Fail to set a process as permanent\n");
* ...
* @endcode
*/
int sysconf_set_permanent(void);
/**
* @fn int sysconf_set_permanent_bypid(pid_t pid)
* @brief This API is used to set a process which has pid as a permanent process.\n
* If the permanent process is dead, system server will relaunch the process automatically.
* @return 0 on success, -1 if failed.
* @see sysconf_set_permanent()
* @par Example
* @code
* ...
* ret = sysconf_set_permanent_bypid(pid);
* if( ret < 0 )
* printf("Fail to set a process(%d) as permanent\n",pid);
* ...
* @endcode
*/
int sysconf_set_permanent_bypid(pid_t pid);
/**
* @fn int sysconf_set_vip(pid_t pid)
* @brief This API is used to set a process which has pid as Very Important Process(VIP) .\n
* If the VIP process is dead, restarter program will be run. \n
* Restarter program may kill almost processes and run rc.local scripts again.
* @param[in] pid process id to be vip
* @return 0 on success, -1 if failed.
* @see sysconf_is_vip
* @par Example
* @code
* ...
* ret = sysconf_set_vip(pid);
* if( ret < 0 )
* printf("Fail to set a process(%d) as VIP\n",pid);
* ...
* @endcode
*/
int sysconf_set_vip(pid_t pid);
/**
* @fn int sysconf_is_vip(pid_t pid)
* @brief This API is used to verify that process which has pid is Very Important Process(VIP) or not.
* @param[in] pid process id to be vip
* @return 1 on success, 0 if failed.
* @see sysconf_set_vip
* @par Example
* @code
* ...
* ret = sysconf_is_vip(pid);
* if(ret)
* printf("process(%d) is Very Important Process\n",pid);
* ...
* @endcode
*/
int sysconf_is_vip(pid_t pid);
int sysman_set_timezone(char *tzpath_str);
int sysman_call_predef_action(const char *type, int num, ...);
int sysman_inform_foregrd(void);
int sysman_inform_backgrd(void);
int sysman_inform_active(pid_t pid);
int sysman_inform_inactive(pid_t pid);
int sysman_request_poweroff(void);
int sysman_request_entersleep(void);
int sysman_request_leavesleep(void);
int sysman_request_reboot(void);
struct mmc_contents {
void (*mmc_cb) (int result, void* data);
void* user_data;
};
int sysman_request_mount_mmc(struct mmc_contents *mmc_data);
int sysman_request_unmount_mmc(struct mmc_contents *mmc_data, int option);
int sysman_request_format_mmc(struct mmc_contents *mmc_data);
int sysman_request_set_cpu_max_frequency(int val);
int sysman_request_set_cpu_min_frequency(int val);
int sysman_release_cpu_max_frequency(void);
int sysman_release_cpu_min_frequency(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ___SYSMAN___ */
|