include/linux/projid.h
Source file repositories/reference/linux-study-clean/include/linux/projid.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/projid.h- Extension
.h- Size
- 2269 bytes
- Lines
- 91
- 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/types.h
Detected Declarations
struct user_namespacefunction __kprojid_valfunction projid_eqfunction projid_ltfunction projid_validfunction kprojid_has_mappingfunction make_kprojidfunction from_kprojidfunction from_kprojid_mungedfunction kprojid_has_mapping
Annotated Snippet
#ifndef _LINUX_PROJID_H
#define _LINUX_PROJID_H
/*
* A set of types for the internal kernel types representing project ids.
*
* The types defined in this header allow distinguishing which project ids in
* the kernel are values used by userspace and which project id values are
* the internal kernel values. With the addition of user namespaces the values
* can be different. Using the type system makes it possible for the compiler
* to detect when we overlook these differences.
*
*/
#include <linux/types.h>
struct user_namespace;
extern struct user_namespace init_user_ns;
typedef __kernel_uid32_t projid_t;
typedef struct {
projid_t val;
} kprojid_t;
static inline projid_t __kprojid_val(kprojid_t projid)
{
return projid.val;
}
#define KPROJIDT_INIT(value) (kprojid_t){ value }
#define INVALID_PROJID KPROJIDT_INIT(-1)
#define OVERFLOW_PROJID 65534
static inline bool projid_eq(kprojid_t left, kprojid_t right)
{
return __kprojid_val(left) == __kprojid_val(right);
}
static inline bool projid_lt(kprojid_t left, kprojid_t right)
{
return __kprojid_val(left) < __kprojid_val(right);
}
static inline bool projid_valid(kprojid_t projid)
{
return !projid_eq(projid, INVALID_PROJID);
}
#ifdef CONFIG_USER_NS
extern kprojid_t make_kprojid(struct user_namespace *from, projid_t projid);
extern projid_t from_kprojid(struct user_namespace *to, kprojid_t projid);
extern projid_t from_kprojid_munged(struct user_namespace *to, kprojid_t projid);
static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t projid)
{
return from_kprojid(ns, projid) != (projid_t)-1;
}
#else
static inline kprojid_t make_kprojid(struct user_namespace *from, projid_t projid)
{
return KPROJIDT_INIT(projid);
}
static inline projid_t from_kprojid(struct user_namespace *to, kprojid_t kprojid)
{
return __kprojid_val(kprojid);
}
static inline projid_t from_kprojid_munged(struct user_namespace *to, kprojid_t kprojid)
{
projid_t projid = from_kprojid(to, kprojid);
if (projid == (projid_t)-1)
projid = OVERFLOW_PROJID;
return projid;
}
static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t projid)
{
return true;
}
#endif /* CONFIG_USER_NS */
#endif /* _LINUX_PROJID_H */
Annotation
- Immediate include surface: `linux/types.h`.
- Detected declarations: `struct user_namespace`, `function __kprojid_val`, `function projid_eq`, `function projid_lt`, `function projid_valid`, `function kprojid_has_mapping`, `function make_kprojid`, `function from_kprojid`, `function from_kprojid_munged`, `function kprojid_has_mapping`.
- 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.