cgroups: rename cgroupfs mount fd

parent a9db9474
...@@ -3084,11 +3084,11 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3084,11 +3084,11 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
if (IS_ERR(current_cgroup)) if (IS_ERR(current_cgroup))
return PTR_ERR(current_cgroup); return PTR_ERR(current_cgroup);
if (unified_cgroup_fd(ops->dfd_mnt_cgroupfs_host)) { if (unified_cgroup_fd(ops->dfd_mnt)) {
dfd_mnt = dup_cloexec(ops->dfd_mnt_cgroupfs_host); dfd_mnt = dup_cloexec(ops->dfd_mnt);
unified_mnt = ""; unified_mnt = "";
} else { } else {
dfd_mnt = open_at(ops->dfd_mnt_cgroupfs_host, dfd_mnt = open_at(ops->dfd_mnt,
"unified", "unified",
PROTECT_OPATH_DIRECTORY, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
...@@ -3096,7 +3096,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3096,7 +3096,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
} }
if (dfd_mnt < 0) { if (dfd_mnt < 0) {
if (errno != ENOENT) if (errno != ENOENT)
return syserrno(-errno, "Failed to open %d/unified", ops->dfd_mnt_cgroupfs_host); return syserrno(-errno, "Failed to open %d/unified", ops->dfd_mnt);
SYSTRACE("Unified cgroup not mounted"); SYSTRACE("Unified cgroup not mounted");
continue; continue;
...@@ -3146,13 +3146,13 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, ...@@ -3146,13 +3146,13 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
if (!controllers) if (!controllers)
return ret_errno(ENOMEM); return ret_errno(ENOMEM);
dfd_mnt = open_at(ops->dfd_mnt_cgroupfs_host, dfd_mnt = open_at(ops->dfd_mnt,
controllers, PROTECT_OPATH_DIRECTORY, controllers, PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
if (dfd_mnt < 0) { if (dfd_mnt < 0) {
if (errno != ENOENT) if (errno != ENOENT)
return syserrno(-errno, "Failed to open %d/%s", return syserrno(-errno, "Failed to open %d/%s",
ops->dfd_mnt_cgroupfs_host, controllers); ops->dfd_mnt, controllers);
SYSTRACE("%s not mounted", controllers); SYSTRACE("%s not mounted", controllers);
continue; continue;
...@@ -3236,7 +3236,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf) ...@@ -3236,7 +3236,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf)
int ret; int ret;
const char *controllers_use; const char *controllers_use;
if (ops->dfd_mnt_cgroupfs_host >= 0) if (ops->dfd_mnt >= 0)
return ret_errno(EBUSY); return ret_errno(EBUSY);
/* /*
...@@ -3270,7 +3270,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf) ...@@ -3270,7 +3270,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf)
* once we know the initialization succeeded. So if we fail we clean up * once we know the initialization succeeded. So if we fail we clean up
* the dfd. * the dfd.
*/ */
ops->dfd_mnt_cgroupfs_host = dfd; ops->dfd_mnt = dfd;
ret = __initialize_cgroups(ops, conf->cgroup_meta.relative, !lxc_list_empty(&conf->id_map)); ret = __initialize_cgroups(ops, conf->cgroup_meta.relative, !lxc_list_empty(&conf->id_map));
if (ret < 0) if (ret < 0)
...@@ -3308,7 +3308,7 @@ struct cgroup_ops *cgroup_ops_init(struct lxc_conf *conf) ...@@ -3308,7 +3308,7 @@ struct cgroup_ops *cgroup_ops_init(struct lxc_conf *conf)
return ret_set_errno(NULL, ENOMEM); return ret_set_errno(NULL, ENOMEM);
cgfsng_ops->cgroup_layout = CGROUP_LAYOUT_UNKNOWN; cgfsng_ops->cgroup_layout = CGROUP_LAYOUT_UNKNOWN;
cgfsng_ops->dfd_mnt_cgroupfs_host = -EBADF; cgfsng_ops->dfd_mnt = -EBADF;
if (initialize_cgroups(cgfsng_ops, conf)) if (initialize_cgroups(cgfsng_ops, conf))
return NULL; return NULL;
......
...@@ -73,8 +73,8 @@ void cgroup_exit(struct cgroup_ops *ops) ...@@ -73,8 +73,8 @@ void cgroup_exit(struct cgroup_ops *ops)
bpf_device_program_free(ops); bpf_device_program_free(ops);
if (ops->dfd_mnt_cgroupfs_host >= 0) if (ops->dfd_mnt >= 0)
close(ops->dfd_mnt_cgroupfs_host); close(ops->dfd_mnt);
for (struct hierarchy **it = ops->hierarchies; it && *it; it++) { for (struct hierarchy **it = ops->hierarchies; it && *it; it++) {
for (char **p = (*it)->controllers; p && *p; p++) for (char **p = (*it)->controllers; p && *p; p++)
......
...@@ -130,7 +130,7 @@ struct cgroup_ops { ...@@ -130,7 +130,7 @@ struct cgroup_ops {
* So for CGROUP_LAYOUT_LEGACY or CGROUP_LAYOUT_HYBRID we allow * So for CGROUP_LAYOUT_LEGACY or CGROUP_LAYOUT_HYBRID we allow
* mountpoint crossing iff we cross from a tmpfs into a cgroupfs mount. * mountpoint crossing iff we cross from a tmpfs into a cgroupfs mount.
* */ * */
int dfd_mnt_cgroupfs_host; int dfd_mnt;
/* What controllers is the container supposed to use. */ /* What controllers is the container supposed to use. */
char **cgroup_use; char **cgroup_use;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment