include/linux/nsproxy.h
Source file repositories/reference/linux-study-clean/include/linux/nsproxy.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/nsproxy.h- Extension
.h- Size
- 3480 bytes
- Lines
- 121
- 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/refcount.hlinux/spinlock.hlinux/sched.h
Detected Declarations
struct mnt_namespacestruct uts_namespacestruct ipc_namespacestruct pid_namespacestruct cgroup_namespacestruct fs_structstruct nsproxystruct nssetfunction put_nsproxyfunction get_nsproxy
Annotated Snippet
struct nsproxy {
refcount_t count;
struct uts_namespace *uts_ns;
struct ipc_namespace *ipc_ns;
struct mnt_namespace *mnt_ns;
struct pid_namespace *pid_ns_for_children;
struct net *net_ns;
struct time_namespace *time_ns;
struct time_namespace *time_ns_for_children;
struct cgroup_namespace *cgroup_ns;
};
extern struct nsproxy init_nsproxy;
/*
* A structure to encompass all bits needed to install
* a partial or complete new set of namespaces.
*
* If a new user namespace is requested cred will
* point to a modifiable set of credentials. If a pointer
* to a modifiable set is needed nsset_cred() must be
* used and tested.
*/
struct nsset {
unsigned flags;
struct nsproxy *nsproxy;
struct fs_struct *fs;
const struct cred *cred;
};
static inline struct cred *nsset_cred(struct nsset *set)
{
if (set->flags & CLONE_NEWUSER)
return (struct cred *)set->cred;
return NULL;
}
/*
* the namespaces access rules are:
*
* 1. only current task is allowed to change tsk->nsproxy pointer or
* any pointer on the nsproxy itself. Current must hold the task_lock
* when changing tsk->nsproxy.
*
* 2. when accessing (i.e. reading) current task's namespaces - no
* precautions should be taken - just dereference the pointers
*
* 3. the access to other task namespaces is performed like this
* task_lock(task);
* nsproxy = task->nsproxy;
* if (nsproxy != NULL) {
* / *
* * work with the namespaces here
* * e.g. get the reference on one of them
* * /
* } / *
* * NULL task->nsproxy means that this task is
* * almost dead (zombie)
* * /
* task_unlock(task);
*
*/
int copy_namespaces(u64 flags, struct task_struct *tsk);
void switch_cred_namespaces(const struct cred *old, const struct cred *new);
void exit_nsproxy_namespaces(struct task_struct *tsk);
void get_cred_namespaces(struct task_struct *tsk);
void exit_cred_namespaces(struct task_struct *tsk);
void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
int exec_task_namespaces(void);
void deactivate_nsproxy(struct nsproxy *ns);
int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
struct cred *, struct fs_struct *);
int __init nsproxy_cache_init(void);
static inline void put_nsproxy(struct nsproxy *ns)
{
if (refcount_dec_and_test(&ns->count))
deactivate_nsproxy(ns);
}
static inline void get_nsproxy(struct nsproxy *ns)
{
refcount_inc(&ns->count);
}
DEFINE_FREE(put_nsproxy, struct nsproxy *, if (_T) put_nsproxy(_T))
#endif
Annotation
- Immediate include surface: `linux/refcount.h`, `linux/spinlock.h`, `linux/sched.h`.
- Detected declarations: `struct mnt_namespace`, `struct uts_namespace`, `struct ipc_namespace`, `struct pid_namespace`, `struct cgroup_namespace`, `struct fs_struct`, `struct nsproxy`, `struct nsset`, `function put_nsproxy`, `function get_nsproxy`.
- 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.