File Index
Files and directories
Sign in
FILE

cgroup_namespace.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/cgroup_namespace.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _LINUX_CGROUP_NAMESPACE_H
 3#define _LINUX_CGROUP_NAMESPACE_H
 4
 5#include <linux/ns_common.h>
 6
 7struct cgroup_namespace {
 8	struct ns_common	ns;
 9	struct user_namespace	*user_ns;
10	struct ucounts		*ucounts;
11	struct css_set          *root_cset;
12};
13
14extern struct cgroup_namespace init_cgroup_ns;
15
16#ifdef CONFIG_CGROUPS
17
18static inline struct cgroup_namespace *to_cg_ns(struct ns_common *ns)
19{
20	return container_of(ns, struct cgroup_namespace, ns);
21}
22
23void free_cgroup_ns(struct cgroup_namespace *ns);
24
25struct cgroup_namespace *copy_cgroup_ns(u64 flags,
26					struct user_namespace *user_ns,
27					struct cgroup_namespace *old_ns);
28
29int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
30		   struct cgroup_namespace *ns);
31
32static inline void get_cgroup_ns(struct cgroup_namespace *ns)
33{
34	ns_ref_inc(ns);
35}
36
37static inline void put_cgroup_ns(struct cgroup_namespace *ns)
38{
39	if (ns_ref_put(ns))
40		free_cgroup_ns(ns);
41}
42
43#else /* !CONFIG_CGROUPS */
44
45static inline void free_cgroup_ns(struct cgroup_namespace *ns) { }
46static inline struct cgroup_namespace *
47copy_cgroup_ns(u64 flags, struct user_namespace *user_ns,
48	       struct cgroup_namespace *old_ns)
49{
50	return old_ns;
51}
52
53static inline void get_cgroup_ns(struct cgroup_namespace *ns) { }
54static inline void put_cgroup_ns(struct cgroup_namespace *ns) { }
55
56#endif /* !CONFIG_CGROUPS */
57
58#endif /* _LINUX_CGROUP_NAMESPACE_H */
~/ Read-only file preview.