/* Open the configuration file. */
pthread_rwlock_wrlock(&rl_lock);
- fp = fopen(CGRULES_CONF_FILE, "r");
+ fp = fopen(CGRULES_CONF_FILE, "re");
if (!fp) {
cgroup_dbg("Failed to open configuration file %s with"
" error: %s\n", CGRULES_CONF_FILE,
pthread_rwlock_wrlock(&cg_mount_table_lock);
- proc_cgroup = fopen("/proc/cgroups", "r");
+ proc_cgroup = fopen("/proc/cgroups", "re");
if (!proc_cgroup) {
last_errno = errno;
}
controllers[i] = NULL;
- proc_mount = fopen("/proc/mounts", "r");
+ proc_mount = fopen("/proc/mounts", "re");
if (proc_mount == NULL) {
ret = ECGFAIL;
goto unlock_exit;
char mntent_buff[4 * FILENAME_MAX];
int ret = 1;
- proc_mount = fopen("/proc/mounts", "r");
+ proc_mount = fopen("/proc/mounts", "re");
if (proc_mount == NULL)
return 0;
int ret = 0;
FILE *tasks = NULL;
- tasks = fopen(path, "w");
+ tasks = fopen(path, "we");
if (!tasks) {
switch (errno) {
case EPERM:
if (!cg_test_mounted_fs())
return ECGROUPNOTMOUNTED;
- control_file = fopen(path, "r+");
+ control_file = fopen(path, "r+e");
if (!control_file) {
if (errno == EPERM) {
len--;
*(path+len+1) = '\0';
strncat(path, "tasks", sizeof(path) - strlen(path));
- control_file = fopen(path, "r");
+ control_file = fopen(path, "re");
if (!control_file) {
if (errno == ENOENT)
return ECGROUPSUBSYSNOTMOUNTED;
return ECGROUPSUBSYSNOTMOUNTED;
strncat(path, "tasks", sizeof(path) - strlen(path));
- delete_tasks = fopen(path, "r");
+ delete_tasks = fopen(path, "re");
if (delete_tasks) {
ret = cg_move_task_files(delete_tasks, target_tasks);
fclose(delete_tasks);
strncat(parent_path, "/tasks", sizeof(parent_path)
- strlen(parent_path));
- parent_tasks = fopen(parent_path, "w");
+ parent_tasks = fopen(parent_path, "we");
if (!parent_tasks) {
last_errno = errno;
ret = ECGOTHER;
return ECGFAIL;
strncat(path, file, sizeof(path) - strlen(path));
- ctrl_file = fopen(path, "r");
+ ctrl_file = fopen(path, "re");
if (!ctrl_file)
return ECGROUPVALUENOTEXIST;
}
ret = ECGROUPNOTEXIST;
- pid_cgroup_fd = fopen(path, "r");
+ pid_cgroup_fd = fopen(path, "re");
if (!pid_cgroup_fd)
goto cleanup_path;
sprintf(stat_file, "%s/%s.stat", stat_file, controller);
- fp = fopen(stat_file, "r");
+ fp = fopen(stat_file, "re");
if (!fp) {
cgroup_dbg("fopen failed\n");
return ECGINVAL;
return ECGOTHER;
}
- *handle = (void *) fopen(fullpath, "r");
+ *handle = (void *) fopen(fullpath, "re");
free(fullpath);
if (!*handle) {
bool found_egid = false;
sprintf(path, "/proc/%d/status", pid);
- f = fopen(path, "r");
+ f = fopen(path, "re");
if (!f)
return ECGROUPNOTEXIST;
char buf[4092];
sprintf(path, "/proc/%d/status", pid);
- f = fopen(path, "r");
+ f = fopen(path, "re");
if (!f)
return ECGROUPNOTEXIST;
return ECGROUPNOTEXIST;
sprintf(path, "/proc/%d/cmdline", pid);
- f = fopen(path, "r");
+ f = fopen(path, "re");
if (!f)
return ECGROUPNOTEXIST;
if (!info)
return ECGINVAL;
- proc_cgroup = fopen("/proc/cgroups", "r");
+ proc_cgroup = fopen("/proc/cgroups", "re");
if (!proc_cgroup) {
last_errno = errno;
return ECGOTHER;