typedef char cont_name_t[FILENAME_MAX];
int flags;
-FILE *of;
+FILE *output_f;
/*
* Display the usage
tag is necessery */
/* print the header */
- fprintf(of, "\tperm {\n");
+ fprintf(output_f, "\tperm {\n");
/* find out the user and group name */
pw = getpwuid(sba.st_uid);
}
/* print the admin record */
- fprintf(of, "\t\tadmin {\n"\
+ fprintf(output_f, "\t\tadmin {\n"\
"\t\t\tuid = %s;\n"\
"\t\t\tgid = %s;\n"\
"\t\t}\n", pw->pw_name, gr->gr_name);
}
/* print the task record */
- fprintf(of, "\t\ttask {\n"\
+ fprintf(output_f, "\t\ttask {\n"\
"\t\t\tuid = %s;\n"\
"\t\t\tgid = %s;\n"\
"\t\t}\n", pw->pw_name, gr->gr_name);
- fprintf(of, "\t}\n");
+ fprintf(output_f, "\t}\n");
}
return 0;
struct stat sb;
/* print the group definition header */
- fprintf(of, "group %s {\n", group->name);
+ fprintf(output_f, "group %s {\n", group->name);
/* for all wanted controllers display controllers tag */
while (controller[i][0] != '\0') {
/* print the controller header */
if (strncmp(controller[i], "name=", 5) == 0)
- fprintf(of, "\t\"%s\" {\n", controller[i]);
+ fprintf(output_f, "\t\"%s\" {\n", controller[i]);
else
- fprintf(of, "\t%s {\n", controller[i]);
+ fprintf(output_f, "\t%s {\n", controller[i]);
i++;
nr_var = cgroup_get_value_name_count(group_controller);
}
if (strcmp("devices.list", name) == 0) {
output_name = "devices.allow";
- fprintf(of,
+ fprintf(output_f,
"\t\tdevices.deny=\"a *:* rwm\";\n");
}
name);
goto err;
}
- fprintf(of, "\t\t%s=\"%s\";\n", output_name, value);
+ fprintf(output_f, "\t\t%s=\"%s\";\n", output_name, value);
free(value);
}
- fprintf(of, "\t}\n");
+ fprintf(output_f, "\t}\n");
}
/* tail of the record */
- fprintf(of, "}\n\n");
+ fprintf(output_f, "}\n\n");
err:
return ret;
while (ret == 0) {
if (quote)
- fprintf(of, "\t\"%s\" = %s;\n", controller, path);
+ fprintf(output_f, "\t\"%s\" = %s;\n", controller, path);
else
- fprintf(of, "\t%s = %s;\n", controller, path);
+ fprintf(output_f, "\t%s = %s;\n", controller, path);
ret = cgroup_get_subsys_mount_point_next(&handle, path);
}
cgroup_get_subsys_mount_point_end(&handle);
struct cgroup_mount_point mount;
/* start mount section */
- fprintf(of, "mount {\n");
+ fprintf(output_f, "mount {\n");
/* go through the controller list */
ret = cgroup_get_all_controller_begin(&handle, &info);
cgroup_get_controller_end(&handle);
/* finish mount section */
- fprintf(of, "}\n\n");
+ fprintf(output_f, "}\n\n");
return final_ret;
}
break;
case 'f':
flags |= FL_OUTPUT;
- of = fopen(optarg, "w");
- if (of == NULL) {
+ output_f = fopen(optarg, "w");
+ if (output_f == NULL) {
fprintf(stderr, "%s: Failed to open file %s\n",
argv[0], optarg);
return ECGOTHER;
}
if ((flags & FL_OUTPUT) == 0)
- of = stdout;
+ output_f = stdout;
/* blacklkist */
if (flags & FL_BLACK) {
goto finish;
/* print the header */
- fprintf(of, "# Configuration file generated by cgsnapshot\n");
+ fprintf(output_f, "# Configuration file generated by cgsnapshot\n");
/* initialize libcgroup */
ret = cgroup_init();
free_list(black_list);
free_list(white_list);
- if (of != stdout)
- fclose(of);
+ if (output_f != stdout)
+ fclose(output_f);
return ret;
}