diff options
author | Unsung <unsung.lee@samsung.com> | 2024-10-11 10:51:34 +0900 |
---|---|---|
committer | Unsung <unsung.lee@samsung.com> | 2024-10-11 15:34:13 +0900 |
commit | e0b67c6b1f63d560d8ec1582716a9d074cefb18f (patch) | |
tree | 56c2248bbb1967284c3e2cbbfb631612b7b61132 | |
parent | d51e2d71e4c137338d583ff2c0e1efaa21821b79 (diff) | |
download | resourced-e0b67c6b1f63d560d8ec1582716a9d074cefb18f.tar.gz resourced-e0b67c6b1f63d560d8ec1582716a9d074cefb18f.tar.bz2 resourced-e0b67c6b1f63d560d8ec1582716a9d074cefb18f.zip |
config-parser: Support limiter.conf in limiter.conf.dtizen_9.0_m2_releaseaccepted/tizen/unified/x/asan/20241022.113428accepted/tizen/unified/x/20241017.170332accepted/tizen/unified/toolchain/20241022.122838accepted/tizen/unified/toolchain/20241022.122354accepted/tizen/unified/20241017.114652accepted/tizen/9.0/unified/20241030.233530accepted/tizen_unified_x_asanaccepted/tizen_unified_xaccepted/tizen_unified_toolchainaccepted/tizen_unified
Support limiter.conf configuration file in limiter.conf.d directory.
Previously, resourced supported only one limiter.conf file included in the project.
Now it has been changed so that each user can replace it with their own limiter.conf file.
Example:
/etc/resourced/limiter.conf -> it will be not used for limiter moudle.
/etc/resourced/limiter.conf.d/limiter.conf -> It will be used for limiter
Change-Id: I59e496c8375667e5a84b5822aeda0df1256993d3
Signed-off-by: Unsung <unsung.lee@samsung.com>
-rw-r--r-- | src/common/conf/config-parser.c | 28 | ||||
-rw-r--r-- | src/common/conf/config-parser.h | 4 |
2 files changed, 30 insertions, 2 deletions
diff --git a/src/common/conf/config-parser.c b/src/common/conf/config-parser.c index ab841391..8a314fd7 100644 --- a/src/common/conf/config-parser.c +++ b/src/common/conf/config-parser.c @@ -1188,14 +1188,34 @@ static int vendor_config(struct parse_result *result, void *user_data) return RESOURCED_ERROR_NONE; } +static int filter_limiter_conf_file(const struct dirent *dirent) +{ + if (dirent == NULL) + return 0; + + return strncmp(dirent->d_name, CONF_FILE_NAME(limiter), + strlen(CONF_FILE_NAME(limiter)) + 1); +} + static void load_per_vendor_configs(const char *dir, int func(struct parse_result *result, void *user_data), void *user_data) { int count; int idx; struct dirent **namelist; + enum config_type config_type = *((enum config_type*)user_data); + int (*filter_func) (const struct dirent *) = NULL; + + switch (config_type) { + case LIMITER_CONFIG: + filter_func = filter_limiter_conf_file; + break; + default: + filter_func = NULL; + break; + } - if ((count = scandir(dir, &namelist, NULL, alphasort)) == -1) { + if ((count = scandir(dir, &namelist, filter_func, alphasort)) == -1) { _I("(%s) conf dir does not exist", dir); return; } @@ -1221,7 +1241,11 @@ void resourced_parse_vendor_configs(void) fixed_app_and_service_list_init(); /* Load configurations in limiter.conf and limiter.conf.d/ */ - config_parse(LIMITER_CONF_FILE, limiter_config, NULL); + if (access(LIMITER_CONF_DIR_LIMITER_CONF, F_OK) != 0) + config_parse(LIMITER_CONF_FILE, limiter_config, NULL); + else + config_parse(LIMITER_CONF_DIR_LIMITER_CONF, limiter_config, NULL); + config_type = LIMITER_CONFIG; load_per_vendor_configs(LIMITER_CONF_DIR, vendor_config, &config_type); diff --git a/src/common/conf/config-parser.h b/src/common/conf/config-parser.h index f7c32490..df9a18d8 100644 --- a/src/common/conf/config-parser.h +++ b/src/common/conf/config-parser.h @@ -30,6 +30,10 @@ extern "C" { #define CONF_FILE_SUFFIX ".conf" +#define CONF_FILE_NAME(conf_name) #conf_name CONF_FILE_SUFFIX + +#define LIMITER_CONF_DIR_LIMITER_CONF LIMITER_CONF_DIR "/" CONF_FILE_NAME(limiter) + #define LIMITER_CONF_FILE RD_CONFIG_FILE(limiter) #define OPTIMIZER_CONF_FILE RD_CONFIG_FILE(optimizer) #define PROCESS_CONF_FILE RD_CONFIG_FILE(process) |