{
if (mkdir(cgroup_full_path,
S_IRUSR | S_IWUSR | S_IRGRP) < 0)
- return -errno;
+ return -errno; //LCOV_EXCL_LINE
return 0;
}
int ret;
if (pid <= 0) {
- STC_LOGE("try to write empty pid to %s", cgroup_full_path);
- return STC_ERROR_NO_DATA;
+ STC_LOGE("try to write empty pid to %s", cgroup_full_path); //LCOV_EXCL_LINE
+ return STC_ERROR_NO_DATA; //LCOV_EXCL_LINE
}
ret = cgroup_write_node_uint32(cgroup_full_path, CGROUP_FILE_NAME,
return cgroup_write_pid_fullpath(buf, pid);
}
+//LCOV_EXCL_START
stc_error_e cgroup_write_pidtree(const char *cgroup_subsystem,
const char *cgroup_name, const int pid)
{
char buf[MAX_PATH_LENGTH];
/*/proc/%d/task/%d/children */
- char child_buf[21 + MAX_DEC_SIZE(int) + MAX_DEC_SIZE(int)];
+ char child_buf[21 + MAX_DEC_SIZE(int) + MAX_DEC_SIZE(int) + 1];
char pidbuf[MAX_DEC_SIZE(int)];
stc_error_e ret;
fclose(f);
return STC_ERROR_NONE;
}
+//LCOV_EXCL_STOP
int cgroup_write_node_uint32(const char *cgroup_name,
const char *file_name, uint32_t value)
char buf[MAX_PATH_LENGTH];
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
- if (STC_DEBUG_LOG)
- STC_LOGD("cgroup_buf %s, value %d\n", buf, value);
+ if (STC_STAT_LOG)
+ STC_LOGD("cgroup_buf %s, value %d\n", buf, value); //LCOV_EXCL_LINE
return fwrite_uint(buf, value);
}
char buf[MAX_PATH_LENGTH];
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
- if (STC_DEBUG_LOG)
- STC_LOGD("cgroup_buf %s, string %s\n", buf, string);
+ if (STC_STAT_LOG)
+ STC_LOGD("cgroup_buf %s, string %s\n", buf, string); //LCOV_EXCL_LINE
return fwrite_str(buf, string);
}
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
ret = fread_uint(buf, value);
- if (STC_DEBUG_LOG)
- STC_LOGD("cgroup_buf %s, value %d\n", buf, *value);
+ if (STC_STAT_LOG)
+ STC_LOGD("cgroup_buf %s, value %d\n", buf, *value); //LCOV_EXCL_LINE
return ret;
}
if (parentdir && !strncmp(parentdir, DEFAULT_CGROUP,
sizeof(DEFAULT_CGROUP))) {
- ret = mount("tmpfs", DEFAULT_CGROUP, "tmpfs",
+ ret = mount("tmpfs", DEFAULT_CGROUP, "tmpfs", //LCOV_EXCL_LINE
MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
"mode=755");
if (ret < 0) {
- STC_LOGE("Fail to RW mount cgroup directory. Can't make %s cgroup", cgroup_name);
- return STC_ERROR_FAIL;
+ STC_LOGE("Fail to RW mount cgroup directory. Can't make %s cgroup", cgroup_name); //LCOV_EXCL_LINE
+ return STC_ERROR_FAIL; //LCOV_EXCL_LINE
}
cgroup_remount = true;
}
cgroup_name, errno);
if (cgroup_remount) {
- ret = mount("tmpfs", DEFAULT_CGROUP, "tmpfs",
+ ret = mount("tmpfs", DEFAULT_CGROUP, "tmpfs", //LCOV_EXCL_LINE
MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME|MS_RDONLY,
"mode=755");
if (ret < 0)
- STC_LOGD("Fail to RO mount");
+ STC_LOGD("Fail to RO mount"); //LCOV_EXCL_LINE
}
}
return cgroup_write_node_str(buf, NOTIFY_ON_RELEASE, "1");
}
-void cgroup_init(void)
+API void cgroup_init(void)
{
/* create stc cgroup directory */
cgroup_make_subdir(CGROUP_NETWORK, STC_CGROUP_NAME, NULL);
cgroup_make_subdir(STC_CGROUP_NETWORK, STC_BACKGROUND_CGROUP_NAME,
NULL);
- cgroup_write_node_uint32(BACKGROUND_CGROUP_NETWORK,
- CLASSID_FILE_NAME, STC_BACKGROUND_APP_CLASSID);
-
/* create foreground cgroup directory */
cgroup_make_subdir(STC_CGROUP_NETWORK, STC_FOREGROUND_CGROUP_NAME,
NULL);
+
+ /* create tethering cgroup directory */
+ cgroup_make_subdir(STC_CGROUP_NETWORK, STC_TETHERING_CGROUP_NAME,
+ NULL);
}