bool flipped_bit = false;
fpath = must_make_path(parent_cgroup, "cpuset.cpus", NULL);
- posscpus = read_file_at(-EBADF, fpath);
+ posscpus = read_file_at(-EBADF, fpath, PROTECT_OPEN, 0);
if (!posscpus)
return log_error_errno(false, errno, "Failed to read file \"%s\"", fpath);
return false;
if (file_exists(__ISOL_CPUS)) {
- isolcpus = read_file_at(-EBADF, __ISOL_CPUS);
+ isolcpus = read_file_at(-EBADF, __ISOL_CPUS, PROTECT_OPEN, 0);
if (!isolcpus)
return log_error_errno(false, errno, "Failed to read file \"%s\"", __ISOL_CPUS);
}
if (file_exists(__OFFLINE_CPUS)) {
- offlinecpus = read_file_at(-EBADF, __OFFLINE_CPUS);
+ offlinecpus = read_file_at(-EBADF, __OFFLINE_CPUS, PROTECT_OPEN, 0);
if (!offlinecpus)
return log_error_errno(false, errno, "Failed to read file \"%s\"", __OFFLINE_CPUS);
char *sep = " \t\n";
char *tok;
- buf = read_file_at(dfd, file);
+ buf = read_file_at(dfd, file, PROTECT_OPEN, 0);
if (!buf)
return NULL;
char *token;
int idx;
- buf = read_file_at(-EBADF, "/sys/kernel/cgroup/delegate");
+ buf = read_file_at(-EBADF, "/sys/kernel/cgroup/delegate", PROTECT_OPEN, 0);
if (!buf) {
for (char **p = standard; p && *p; p++) {
idx = append_null_to_list((void ***)delegate);
* cgroups as our base in that case.
*/
if (!relative && (geteuid() == 0))
- basecginfo = read_file_at(-EBADF, "/proc/1/cgroup");
+ basecginfo = read_file_at(-EBADF, "/proc/1/cgroup", PROTECT_OPEN, 0);
else
- basecginfo = read_file_at(-EBADF, "/proc/self/cgroup");
+ basecginfo = read_file_at(-EBADF, "/proc/self/cgroup", PROTECT_OPEN, 0);
if (!basecginfo)
return ret_set_errno(-1, ENOMEM);
char *base_cgroup;
if (!relative && (geteuid() == 0))
- basecginfo = read_file_at(-EBADF, "/proc/1/cgroup");
+ basecginfo = read_file_at(-EBADF, "/proc/1/cgroup", PROTECT_OPEN, 0);
else
- basecginfo = read_file_at(-EBADF, "/proc/self/cgroup");
+ basecginfo = read_file_at(-EBADF, "/proc/self/cgroup", PROTECT_OPEN, 0);
if (!basecginfo)
return NULL;
}
/* Slurp in a whole file */
-char *read_file_at(int dfd, const char *fnam)
+char *read_file_at(int dfd, const char *fnam,
+ unsigned int o_flags, unsigned resolve_flags)
{
__do_close int fd = -EBADF;
__do_free char *buf = NULL, *line = NULL;
size_t len = 0, fulllen = 0;
int linelen;
- fd = openat(dfd, fnam, O_NOCTTY | O_CLOEXEC | O_NOFOLLOW | O_RDONLY);
+ fd = open_at(dfd, fnam, o_flags, resolve_flags, 0);
if (fd < 0)
return NULL;