include/linux/nstree.h
Source file repositories/reference/linux-study-clean/include/linux/nstree.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/nstree.h- Extension
.h- Size
- 3385 bytes
- Lines
- 97
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ns/nstree_types.hlinux/nsproxy.hlinux/rbtree.hlinux/seqlock.hlinux/rculist.hlinux/cookie.huapi/linux/nsfs.h
Detected Declarations
struct ns_commonfunction __ns_tree_add
Annotated Snippet
#ifndef _LINUX_NSTREE_H
#define _LINUX_NSTREE_H
#include <linux/ns/nstree_types.h>
#include <linux/nsproxy.h>
#include <linux/rbtree.h>
#include <linux/seqlock.h>
#include <linux/rculist.h>
#include <linux/cookie.h>
#include <uapi/linux/nsfs.h>
struct ns_common;
extern struct ns_tree_root cgroup_ns_tree;
extern struct ns_tree_root ipc_ns_tree;
extern struct ns_tree_root mnt_ns_tree;
extern struct ns_tree_root net_ns_tree;
extern struct ns_tree_root pid_ns_tree;
extern struct ns_tree_root time_ns_tree;
extern struct ns_tree_root user_ns_tree;
extern struct ns_tree_root uts_ns_tree;
void ns_tree_node_init(struct ns_tree_node *node);
void ns_tree_root_init(struct ns_tree_root *root);
bool ns_tree_node_empty(const struct ns_tree_node *node);
struct rb_node *ns_tree_node_add(struct ns_tree_node *node,
struct ns_tree_root *root,
int (*cmp)(struct rb_node *, const struct rb_node *));
void ns_tree_node_del(struct ns_tree_node *node, struct ns_tree_root *root);
#define to_ns_tree(__ns) \
_Generic((__ns), \
struct cgroup_namespace *: &(cgroup_ns_tree), \
struct ipc_namespace *: &(ipc_ns_tree), \
struct net *: &(net_ns_tree), \
struct pid_namespace *: &(pid_ns_tree), \
struct mnt_namespace *: &(mnt_ns_tree), \
struct time_namespace *: &(time_ns_tree), \
struct user_namespace *: &(user_ns_tree), \
struct uts_namespace *: &(uts_ns_tree))
#define ns_tree_gen_id(__ns) \
__ns_tree_gen_id(to_ns_common(__ns), \
(((__ns) == ns_init_ns(__ns)) ? ns_init_id(__ns) : 0))
u64 __ns_tree_gen_id(struct ns_common *ns, u64 id);
void __ns_tree_add_raw(struct ns_common *ns, struct ns_tree_root *ns_tree);
void __ns_tree_remove(struct ns_common *ns, struct ns_tree_root *ns_tree);
struct ns_common *ns_tree_lookup_rcu(u64 ns_id, int ns_type);
struct ns_common *__ns_tree_adjoined_rcu(struct ns_common *ns,
struct ns_tree_root *ns_tree,
bool previous);
static inline void __ns_tree_add(struct ns_common *ns, struct ns_tree_root *ns_tree, u64 id)
{
__ns_tree_gen_id(ns, id);
__ns_tree_add_raw(ns, ns_tree);
}
/**
* ns_tree_add_raw - Add a namespace to a namespace
* @__ns: Namespace to add
*
* This function adds a namespace to the appropriate namespace tree
* without assigning a id.
*/
#define ns_tree_add_raw(__ns) __ns_tree_add_raw(to_ns_common(__ns), to_ns_tree(__ns))
/**
* ns_tree_add - Add a namespace to a namespace tree
* @__ns: Namespace to add
*
* This function assigns a new id to the namespace and adds it to the
* appropriate namespace tree and list.
*/
#define ns_tree_add(__ns) \
__ns_tree_add(to_ns_common(__ns), to_ns_tree(__ns), \
(((__ns) == ns_init_ns(__ns)) ? ns_init_id(__ns) : 0))
/**
* ns_tree_remove - Remove a namespace from a namespace tree
* @__ns: Namespace to remove
*
* This function removes a namespace from the appropriate namespace
* tree and list.
*/
#define ns_tree_remove(__ns) __ns_tree_remove(to_ns_common(__ns), to_ns_tree(__ns))
#define ns_tree_adjoined_rcu(__ns, __previous) \
__ns_tree_adjoined_rcu(to_ns_common(__ns), to_ns_tree(__ns), __previous)
Annotation
- Immediate include surface: `linux/ns/nstree_types.h`, `linux/nsproxy.h`, `linux/rbtree.h`, `linux/seqlock.h`, `linux/rculist.h`, `linux/cookie.h`, `uapi/linux/nsfs.h`.
- Detected declarations: `struct ns_common`, `function __ns_tree_add`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.