From e18e9053941337d646b32b65172c1f9e56bc1bca Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sun, 21 Feb 2021 10:54:23 +0100 Subject: [PATCH] cgroups: rename cgroupfs mount fd Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 18 +++++++++--------- src/lxc/cgroups/cgroup.c | 4 ++-- src/lxc/cgroups/cgroup.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 4c2eb48f3..cb36abc5b 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -3084,11 +3084,11 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, if (IS_ERR(current_cgroup)) return PTR_ERR(current_cgroup); - if (unified_cgroup_fd(ops->dfd_mnt_cgroupfs_host)) { - dfd_mnt = dup_cloexec(ops->dfd_mnt_cgroupfs_host); + if (unified_cgroup_fd(ops->dfd_mnt)) { + dfd_mnt = dup_cloexec(ops->dfd_mnt); unified_mnt = ""; } else { - dfd_mnt = open_at(ops->dfd_mnt_cgroupfs_host, + dfd_mnt = open_at(ops->dfd_mnt, "unified", PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); @@ -3096,7 +3096,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, } if (dfd_mnt < 0) { 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"); continue; @@ -3146,13 +3146,13 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, if (!controllers) return ret_errno(ENOMEM); - dfd_mnt = open_at(ops->dfd_mnt_cgroupfs_host, + dfd_mnt = open_at(ops->dfd_mnt, controllers, PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_ABSOLUTE_XDEV, 0); if (dfd_mnt < 0) { if (errno != ENOENT) return syserrno(-errno, "Failed to open %d/%s", - ops->dfd_mnt_cgroupfs_host, controllers); + ops->dfd_mnt, controllers); SYSTRACE("%s not mounted", controllers); continue; @@ -3236,7 +3236,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf) int ret; const char *controllers_use; - if (ops->dfd_mnt_cgroupfs_host >= 0) + if (ops->dfd_mnt >= 0) return ret_errno(EBUSY); /* @@ -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 * 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)); if (ret < 0) @@ -3308,7 +3308,7 @@ struct cgroup_ops *cgroup_ops_init(struct lxc_conf *conf) return ret_set_errno(NULL, ENOMEM); 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)) return NULL; diff --git a/src/lxc/cgroups/cgroup.c b/src/lxc/cgroups/cgroup.c index 469660655..fa40fc8e6 100644 --- a/src/lxc/cgroups/cgroup.c +++ b/src/lxc/cgroups/cgroup.c @@ -73,8 +73,8 @@ void cgroup_exit(struct cgroup_ops *ops) bpf_device_program_free(ops); - if (ops->dfd_mnt_cgroupfs_host >= 0) - close(ops->dfd_mnt_cgroupfs_host); + if (ops->dfd_mnt >= 0) + close(ops->dfd_mnt); for (struct hierarchy **it = ops->hierarchies; it && *it; it++) { for (char **p = (*it)->controllers; p && *p; p++) diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h index daca3f60f..47945781e 100644 --- a/src/lxc/cgroups/cgroup.h +++ b/src/lxc/cgroups/cgroup.h @@ -130,7 +130,7 @@ struct cgroup_ops { * So for CGROUP_LAYOUT_LEGACY or CGROUP_LAYOUT_HYBRID we allow * 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. */ char **cgroup_use; -- 2.47.2