-#define GTP_ADD_BIN "/sys/kernel/debug/swap/got_patcher/by_path/add"
+#define GTP_ADD_BY_PATH "/sys/kernel/debug/swap/got_patcher/by_path/add"
+#define GTP_ADD_BY_PID "/sys/kernel/debug/swap/got_patcher/by_pid/add"
+#define GTP_ADD_BY_ID "/sys/kernel/debug/swap/got_patcher/by_id/add"
static int add_bins_to_gtp(struct user_space_inst_t *us_inst)
{
struct app_list_t *app = us_inst->app_inst_list;
uint32_t total_maps_count = 0;
char real_path_buf[PATH_MAX];
- char *resolved;
+ char *to_write;
FILE *gtp_p;
- gtp_p = fopen(GTP_ADD_BIN, "w");
- if (gtp_p == NULL)
- return -EINVAL;
-
while (app != NULL) {
- resolved = realpath((const char *)app->app->exe_path, real_path_buf);
- if (resolved != NULL) {
- total_maps_count++;
- fwrite(resolved, strlen(resolved) + 1, 1, gtp_p);
- fflush(gtp_p);
+ switch (app->app->app_type) {
+ case APP_TYPE_TIZEN:
+ case APP_TYPE_COMMON:
+ gtp_p = fopen(GTP_ADD_BY_PATH, "w");
+ if (gtp_p == NULL) {
+ LOGE("Cannot open <%s> to write!",
+ GTP_ADD_BY_PATH);
+ break;
+ }
- LOGI("app #%u <%s>\n", total_maps_count, resolved);
+ to_write = realpath((const char *)app->app->exe_path,
+ real_path_buf);
+ if (to_write != NULL) {
+ total_maps_count++;
+ fwrite(to_write, strlen(to_write) + 1, 1,
+ gtp_p);
+ fflush(gtp_p);
+
+ LOGI("app #%u <%s>\n", total_maps_count,
+ to_write);
+ }
+ fclose(gtp_p);
+ break;
+ case APP_TYPE_RUNNING:
+ /* TODO Support already running */
+ break;
+ case APP_TYPE_WEB:
+ gtp_p = fopen(GTP_ADD_BY_ID, "w");
+ if (gtp_p == NULL) {
+ LOGE("Cannot open <%s> to write!",
+ GTP_ADD_BY_ID);
+ break;
+ }
+
+ to_write = app->app->app_id;
+ if (to_write != NULL) {
+ total_maps_count++;
+ fwrite(to_write, strlen(to_write) + 1, 1,
+ gtp_p);
+ fflush(gtp_p);
+
+ LOGI("app #%u <%s>\n", total_maps_count,
+ to_write);
+ }
+ fclose(gtp_p);
+ break;
}
app = (struct app_list_t *)app->next;
}
- fclose(gtp_p);
return 0;
}
-#undef GTP_ADD_BIN
+#undef GTP_ADD_BY_ID
+#undef GTP_ADD_BY_PID
+#undef GTP_ADD_BY_PATH
#define GTP_CLEAN "/sys/kernel/debug/swap/got_patcher/del_all"