vip : remove vip-agent module. 18/137218/3
authorKichan Kwon <k_c.kwon@samsung.com>
Wed, 5 Jul 2017 02:16:05 +0000 (11:16 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Mon, 10 Jul 2017 05:25:19 +0000 (14:25 +0900)
- Faultd will work this function

Change-Id: I5303d2353545c2cfae2e9d79bee8479b422d6676
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
CMakeLists.txt
packaging/resourced.spec
src/CMakeLists.txt
src/vip-agent/vip-process.c [deleted file]
src/vip-agent/vip-process.conf [deleted file]
src/vip-agent/vip-process.h [deleted file]
src/vip-agent/vip-release-agent.c [deleted file]

index e7710484f942796d2cf544ac80e0e2344f837ab5..2f856250f5165010451b334f5ce814327a323615 100644 (file)
@@ -56,7 +56,6 @@ SET(FREEZER_SOURCE_DIR          ${SOURCE_DIR}/freezer)
 SET(HEART_SOURCE_DIR            ${SOURCE_DIR}/heart)
 SET(COMMON_SOURCE_DIR           ${SOURCE_DIR}/common)
 SET(CPU_SOURCE_DIR              ${SOURCE_DIR}/cpu)
-SET(VIP_SOURCE_DIR              ${SOURCE_DIR}/vip-agent)
 SET(TIMER_SOURCE_DIR            ${SOURCE_DIR}/timer-slack)
 SET(BLOCK_SOURCE_DIR            ${SOURCE_DIR}/block)
 
index 75979a0e051e9eee3f96339fc61a393983f78034..bca241221efb1bc04f1d20a40cfbe76891fdafe1 100644 (file)
@@ -19,7 +19,6 @@ Source0:    %{name}-%{version}.tar.gz
 %define mem_stress                     OFF
 %define swap_module                    ON
 %define timer_slack                    OFF
-%define vip_agent_module       ON
 
 %define memory_eng                     ON
 %define debug_log                      OFF
@@ -118,7 +117,6 @@ pushd build_light
         -DMEM_STRESS=%{mem_stress} \
         -DSWAP_MODULE=%{swap_module} \
         -DTIMER_SLACK=%{timer_slack} \
-        -DVIP_AGENT=%{vip_agent_module} \
         -DMEMORY_ENG=%{memory_eng} \
         -DDEBUG_LOG=%{debug_log} \
         -DDATAUSAGE_TYPE=NFACCT \
@@ -151,7 +149,6 @@ popd
         -DMEM_STRESS=%{mem_stress} \
         -DSWAP_MODULE=%{swap_module} \
         -DTIMER_SLACK=%{timer_slack} \
-        -DVIP_AGENT=%{vip_agent_module} \
         -DMEMORY_ENG=%{memory_eng} \
         -DDEBUG_LOG=%{debug_log} \
         -DDATAUSAGE_TYPE=NFACCT \
@@ -223,10 +220,6 @@ mv %{_bindir}/resourced.common %{_bindir}/resourced
 %if %{?swap_module} == ON
        %config %{rd_config_path}/swap.conf
 %endif
-%if %{?vip_agent_module} == ON
-       %config %{rd_config_path}/vip-process.conf
-       %attr(-,root, root) %{_bindir}/vip-release-agent
-%endif
 %if %{?timer_slack} == ON
        %config %{rd_config_path}/timer-slack.conf
 %endif
@@ -268,10 +261,6 @@ mv %{_bindir}/resourced %{_bindir}/resourced.light
 %if %{?swap_module} == ON
        %config %{rd_config_path}/swap.conf
 %endif
-%if %{?vip_agent_module} == ON
-       %config %{rd_config_path}/vip-process.conf
-       %attr(-,root, root) %{_bindir}/vip-release-agent
-%endif
 %if %{?timer_slack} == ON
        %config %{rd_config_path}/timer-slack.conf
 %endif
index aa2aa261364af315ca3e10b13be2a9bf0c9fd04d..55af06d0a8b927b6512af66889c4092f2b71234d 100644 (file)
@@ -62,12 +62,6 @@ ELSE()
    SET(SOURCES ${SOURCES} ${FREEZER_SOURCE_DIR}/freezer-common.c)
 ENDIF()
 
-IF("${VIP_AGENT}" STREQUAL "ON")
-  SET(SOURCES ${SOURCES}
-    ${VIP_SOURCE_DIR}/vip-process.c
-    )
-ENDIF()
-
 #heart module
 IF("${HEART_MODULE}" STREQUAL "ON")
   FILE(GLOB FILES "${HEART_SOURCE_DIR}/*.c")
@@ -212,15 +206,6 @@ IF("${TIMER_SLACK}" STREQUAL "ON")
          DESTINATION ${RD_CONFIG_PATH} RENAME timer-slack.conf)
 ENDIF()
 
-IF("${VIP_AGENT}" STREQUAL "ON")
-  ADD_EXECUTABLE(vip-release-agent ${VIP_SOURCE_DIR}/vip-release-agent.c)
-  TARGET_LINK_LIBRARIES(vip-release-agent resourced_shared dlog)
-  INSTALL(TARGETS vip-release-agent DESTINATION bin)
-  INSTALL(FILES ${VIP_SOURCE_DIR}/vip-process.conf
-    DESTINATION
-       ${RD_CONFIG_PATH} RENAME vip-process.conf)
-ENDIF()
-
 IF("${BLOCK_MODULE}" STREQUAL "ON")
        INSTALL(FILES ${BLOCK_SOURCE_DIR}/block.conf
                DESTINATION ${RD_CONFIG_PATH} RENAME block.conf)
diff --git a/src/vip-agent/vip-process.c b/src/vip-agent/vip-process.c
deleted file mode 100644 (file)
index 4a41adf..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * resourced
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- *
-*/
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "const.h"
-#include "resourced.h"
-#include "trace.h"
-#include "cgroup.h"
-#include "procfs.h"
-#include "macro.h"
-#include "util.h"
-#include "config-parser.h"
-#include "file-helper.h"
-#include "storage-helper.h"
-#include "notifier.h"
-#include "module.h"
-#include "module-data.h"
-#include "vip-process.h"
-
-#define VIP_CONF_FILE          RD_CONFIG_FILE(vip-process)
-
-static char **arg_vip_proc_names = NULL;
-static char **arg_vip_systemd_services = NULL;
-
-static int vip_load_config(struct parse_result *result, void *user_data)
-{
-       char ***strv;
-       char **temp, **templist;
-
-       if (strncmp(result->section, "VIP_PROCESS", sizeof("VIP_PROCESS") + 1)) {
-               _E("Invalid section name %s", result->section);
-               return -1;
-       }
-
-       if (!result->name || !result->value) {
-               _E("lvalue or rvalue is empty");
-               return -1;
-       }
-
-       if (!strncmp(result->name, "VIP_PROC_NAME", sizeof("VIP_PROC_NAME") + 1))
-               strv = &arg_vip_proc_names;
-       else if (!strncmp(result->name, "VIP_SYSTEMD_SERVICE", sizeof("VIP_SYSTEMD_SERVICE") + 1))
-               strv = &arg_vip_systemd_services;
-       else {
-               _E("Invalid lvalue %s", result->name);
-               return -1;
-       }
-
-       if (str_to_strv(result->value, &temp, WHITESPACE) < 0) {
-               _E("Failed to convert str to strv");
-               return -1;
-       }
-
-       if (strv_attach(*strv, temp, &templist, true) < 0) {
-               _E("Failed to add %s to VIP list", result->value);
-               return -1;
-       }
-
-       *strv = templist;
-       return 0;
-}
-
-static int vip_create_sub_cgroup(const char *name, pid_t pid)
-{
-       _cleanup_free_ char *cgroup_name = NULL;
-       bool already;
-       int r;
-
-       assert(name);
-       assert(pid);
-
-       r = cgroup_make_subdir(VIP_CGROUP, name, &already);
-       if (r < 0) {
-               _E("failed to create vip sub dir");
-               return r;
-       }
-
-       if (already) {
-               _D("PID(%d) is already registered as VIP sub cgroup(%s)",
-                  pid, name);
-               return 0;
-       }
-
-       r = asprintf(&cgroup_name, "%s/%s", VIP_CGROUP, name);
-       if (r < 0) {
-               _E("failed to allocate memory");
-               return -ENOMEM;
-       }
-
-       r = cgroup_write_node_uint32(cgroup_name, TASK_FILE_NAME, pid);
-       if (r < 0) {
-               _E("failed to write pid '%d' to '%s': %m",
-                  pid, cgroup_name);
-               return r;
-       }
-
-       _D("PID(%d) is registered as VIP sub cgroup(%s)", pid, name);
-
-       return 0;
-}
-
-static void vip_create_proc_name_groups(void)
-{
-       char **pname = NULL;
-       int r;
-
-       if (!arg_vip_proc_names)
-               return;
-
-       FOREACH_STRV(pname, arg_vip_proc_names) {
-               pid_t pid = 0;
-
-               pid = find_pid_from_cmdline(*pname);
-               if (pid > 0) {
-                       r = vip_create_sub_cgroup(*pname, pid);
-                       if (r < 0)
-                               _E("failed to create "
-                                  "sub cgroup of '%s', ignoring", *pname);
-               } else
-                       _D("failed to find pid of name: %s", *pname);
-       }
-}
-
-static void vip_create_systemd_service_groups(void)
-{
-       char **pname = NULL;
-
-       if (!arg_vip_systemd_services)
-               return;
-
-       FOREACH_STRV(pname, arg_vip_systemd_services) {
-               _cleanup_free_ char *err_msg = NULL;
-               int r;
-               char path[128];
-               FILE *fp;
-               pid_t pid;
-
-               if (snprintf(path, sizeof(path), "%s/systemd/system.slice/%s/tasks",
-                                       DEFAULT_CGROUP, *pname) < 0) {
-                       _E("Fail to make task path");
-                       continue;
-               }
-
-               fp = fopen(path, "r");
-               if (!fp) {
-                       _E("%s is user level service or not running", *pname);
-                       continue;
-               }
-
-               if (fscanf(fp, "%d", &pid) < 0) {
-                       _E("Fail to get pid of %s", *pname);
-                       fclose(fp);
-                       continue;
-               }
-               if (pid > 0) {
-                       r = vip_create_sub_cgroup(*pname, pid);
-                       if (r < 0)
-                               _E("failed to create "
-                                  "sub cgroup of '%s', ignoring", *pname);
-               }
-
-               fclose(fp);
-       }
-}
-
-static int vip_booting_done(void *data)
-{
-       vip_create_proc_name_groups();
-       vip_create_systemd_service_groups();
-
-       return 0;
-}
-
-static int resourced_vip_process_init(void *data)
-{
-       _cleanup_close_ int checkfd = -1;
-       int r;
-
-       r = access(CHECK_RELEASE_PROGRESS, F_OK);
-       if (r == 0) {
-               r = unlink(CHECK_RELEASE_PROGRESS);
-               if (r < 0)
-                       _E("failed to remove %s: %m", CHECK_RELEASE_PROGRESS);
-       }
-
-       r = config_parse(VIP_CONF_FILE, vip_load_config, NULL);
-       if (r < 0) {
-               _E("failed to parse vip config file: %m");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       if (!arg_vip_proc_names)
-               return RESOURCED_ERROR_NONE;
-
-       if (!is_mounted(VIP_CGROUP)) {
-               r = cgroup_make_subdir(DEFAULT_CGROUP, "vip", NULL);
-               if (r < 0) {
-                       _E("failed to make vip cgroup");
-                       return RESOURCED_ERROR_FAIL;
-               }
-
-               r = cgroup_mount_subsystem("vip_cgroup", VIP_CGROUP,
-                                          "none,name=vip_cgroup");
-               if (r < 0) {
-                       _E("failed to mount vip cgroup: %m");
-                       return RESOURCED_ERROR_FAIL;
-               }
-
-               r = cgroup_set_release_agent("vip", "/usr/bin/vip-release-agent");
-               if (r < 0) {
-                       _E("failed to set vip release agent: %m");
-                       return RESOURCED_ERROR_FAIL;
-               }
-       }
-
-       vip_create_proc_name_groups();
-       vip_create_systemd_service_groups();
-
-       r = register_notifier(RESOURCED_NOTIFIER_BOOTING_DONE,
-                             vip_booting_done);
-       if (r < 0) {
-               _E("failed to register notifier BootingDone");
-               return RESOURCED_ERROR_FAIL;
-       }
-
-       return RESOURCED_ERROR_NONE;
-}
-
-static int resourced_vip_process_finalize(void *data)
-{
-       strv_free_full(arg_vip_proc_names);
-       strv_free_full(arg_vip_systemd_services);
-
-       unregister_notifier(RESOURCED_NOTIFIER_BOOTING_DONE, vip_booting_done);
-
-       return RESOURCED_ERROR_NONE;
-}
-
-static struct module_ops vip_modules_ops = {
-       .priority = MODULE_PRIORITY_NORMAL,
-       .name = "vip-process",
-       .init = resourced_vip_process_init,
-       .exit = resourced_vip_process_finalize,
-};
-
-MODULE_REGISTER(&vip_modules_ops)
diff --git a/src/vip-agent/vip-process.conf b/src/vip-agent/vip-process.conf
deleted file mode 100644 (file)
index 19d83f8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-[VIP_PROCESS]
-# VIP process list
-VIP_PROC_NAME=enlightenment
-VIP_SYSTEMD_SERVICE=dbus.service
diff --git a/src/vip-agent/vip-process.h b/src/vip-agent/vip-process.h
deleted file mode 100644 (file)
index 70445c4..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * resourced
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- *
- */
-
-/**
- * @file proc-monitor.h
- * @desc  proc monitor
- **/
-
-#ifndef __RESOURCED_VIP_PROCESS_H__
-#define __RESOURCED_VIP_PROCESS_H__
-
-#define CHECK_RELEASE_PROGRESS "/tmp/.release_ongoing"
-#define VIP_CGROUP             "/sys/fs/cgroup/vip"
-
-#endif /* __RESOURCED_VIP_PROCESS_H__ */
-
diff --git a/src/vip-agent/vip-release-agent.c b/src/vip-agent/vip-release-agent.c
deleted file mode 100644 (file)
index 50b642b..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <sys/mount.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include "trace.h"
-#include "vip-process.h"
-
-#define TIZEN_DEBUG_MODE_FILE   RD_SYS_ETC"/.debugmode"
-#define DUMP_PATH "/usr/bin/all_log_dump.sh"
-#define REBOOT_PATH "/usr/sbin/reboot"
-#define WAIT_TIMEOUT 10
-#define MAX_TIMES 30
-
-static int check_debugenable(void)
-{
-       if (access(TIZEN_DEBUG_MODE_FILE, F_OK) == 0)
-               return 1;
-       else
-               return 0;
-}
-
-static int run_exec(char **argv)
-{
-       int status = 0, times = 0, wpid;
-       pid_t pid = 0;
-
-       if (argv == NULL)
-               return -3;
-
-       pid = fork();
-
-       if (pid == -1)
-               return -1;
-
-       if (pid == 0) {
-               setpgid(0, 0);
-               if (execv(argv[0], argv) == -1) {
-                       _E("Error execv: %m.\n");
-                       _exit(-1);
-               }
-               _exit(1);
-       }
-       do {
-               wpid = waitpid(pid, &status, WNOHANG);
-               if (wpid == 0) {
-                       if (times < MAX_TIMES) {
-                               sleep(WAIT_TIMEOUT);
-                               times++;
-                       } else {
-                               _D("timeout!!, kill child process(%s)\n",
-                                   argv[0]);
-                               kill(pid, SIGKILL);
-                       }
-               }
-       } while (wpid == 0 && times <= MAX_TIMES);
-       return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       int checkfd;
-       char *dumpargv[3] = {DUMP_PATH, "urgent", NULL};
-       char *rebootargv[4] = {REBOOT_PATH, "silent", NULL, NULL};
-       DIR *dir = 0;
-
-       dir = opendir(VIP_CGROUP);
-       if (!dir) {
-               _E("doesn't support cgroup release agent");
-               return 0;
-       }
-       closedir(dir);
-
-       _E("call release agent : [%d:%s]\n", argc, argv[1]);
-
-       /* check previous process */
-       if (access(CHECK_RELEASE_PROGRESS, F_OK) == 0)
-               return 0;
-
-       /* make tmp file */
-       checkfd = creat(CHECK_RELEASE_PROGRESS, 0640);
-       if (checkfd < 0) {
-               _E("fail to make %s file\n", CHECK_RELEASE_PROGRESS);
-               checkfd = 0;
-       }
-
-       /* unmount cgroup for preventing launching another release-agent */
-       _E("systemd service stop");
-       umount2("/sys/fs/cgroup", MNT_FORCE |MNT_DETACH);
-
-       /* check debug level */
-       if (check_debugenable())
-               run_exec(dumpargv);
-
-       /* clear tmp file */
-       if (checkfd) {
-               if (unlink(CHECK_RELEASE_PROGRESS) < 0)
-                       _E("fail to remove %s file\n", CHECK_RELEASE_PROGRESS);
-               close(checkfd);
-       }
-
-       sync();
-
-       run_exec(rebootargv);
-       return 0;
-}
-