include/linux/time_namespace.h
Source file repositories/reference/linux-study-clean/include/linux/time_namespace.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/time_namespace.h- Extension
.h- Size
- 4254 bytes
- Lines
- 178
- 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/sched.hlinux/nsproxy.hlinux/ns_common.hlinux/err.hlinux/time64.hlinux/cleanup.h
Detected Declarations
struct user_namespacestruct seq_filestruct vm_area_structstruct timens_offsetsstruct time_namespacestruct proc_timens_offsetfunction put_time_nsfunction timens_add_monotonicfunction timens_add_boottimefunction timens_add_boottime_nsfunction timens_sub_boottimefunction timens_ktime_to_hostfunction time_ns_initfunction put_time_nsfunction timens_on_forkfunction timens_add_monotonicfunction timens_sub_boottimefunction timens_commit
Annotated Snippet
struct timens_offsets {
struct timespec64 monotonic;
struct timespec64 boottime;
};
struct time_namespace {
struct user_namespace *user_ns;
struct ucounts *ucounts;
struct ns_common ns;
struct timens_offsets offsets;
#ifdef CONFIG_TIME_NS_VDSO
struct page *vvar_page;
#endif
/* If set prevents changing offsets after any task joined namespace. */
bool frozen_offsets;
} __randomize_layout;
extern struct time_namespace init_time_ns;
#ifdef CONFIG_TIME_NS
static inline struct time_namespace *to_time_ns(struct ns_common *ns)
{
return container_of(ns, struct time_namespace, ns);
}
void __init time_ns_init(void);
static inline struct time_namespace *get_time_ns(struct time_namespace *ns)
{
ns_ref_inc(ns);
return ns;
}
struct time_namespace *copy_time_ns(u64 flags,
struct user_namespace *user_ns,
struct time_namespace *old_ns);
void free_time_ns(struct time_namespace *ns);
void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk);
static inline void put_time_ns(struct time_namespace *ns)
{
if (ns_ref_put(ns))
free_time_ns(ns);
}
void proc_timens_show_offsets(struct task_struct *p, struct seq_file *m);
struct proc_timens_offset {
int clockid;
struct timespec64 val;
};
int proc_timens_set_offset(struct file *file, struct task_struct *p,
struct proc_timens_offset *offsets, int n);
static inline void timens_add_monotonic(struct timespec64 *ts)
{
struct timens_offsets *ns_offsets = ¤t->nsproxy->time_ns->offsets;
*ts = timespec64_add(*ts, ns_offsets->monotonic);
}
static inline void timens_add_boottime(struct timespec64 *ts)
{
struct timens_offsets *ns_offsets = ¤t->nsproxy->time_ns->offsets;
*ts = timespec64_add(*ts, ns_offsets->boottime);
}
static inline u64 timens_add_boottime_ns(u64 nsec)
{
struct timens_offsets *ns_offsets = ¤t->nsproxy->time_ns->offsets;
return nsec + timespec64_to_ns(&ns_offsets->boottime);
}
static inline void timens_sub_boottime(struct timespec64 *ts)
{
struct timens_offsets *ns_offsets = ¤t->nsproxy->time_ns->offsets;
*ts = timespec64_sub(*ts, ns_offsets->boottime);
}
ktime_t do_timens_ktime_to_host(clockid_t clockid, ktime_t tim,
struct timens_offsets *offsets);
static inline ktime_t timens_ktime_to_host(clockid_t clockid, ktime_t tim)
{
struct time_namespace *ns = current->nsproxy->time_ns;
if (likely(ns == &init_time_ns))
Annotation
- Immediate include surface: `linux/sched.h`, `linux/nsproxy.h`, `linux/ns_common.h`, `linux/err.h`, `linux/time64.h`, `linux/cleanup.h`.
- Detected declarations: `struct user_namespace`, `struct seq_file`, `struct vm_area_struct`, `struct timens_offsets`, `struct time_namespace`, `struct proc_timens_offset`, `function put_time_ns`, `function timens_add_monotonic`, `function timens_add_boottime`, `function timens_add_boottime_ns`.
- 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.