Lines Matching refs:ns

61 static struct ucounts *inc_pid_namespaces(struct user_namespace *ns)
63 return inc_ucount(ns, current_euid(), UCOUNT_PID_NAMESPACES);
74 struct pid_namespace *ns;
91 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL);
92 if (ns == NULL)
95 idr_init(&ns->idr);
97 ns->pid_cachep = create_pid_cachep(level);
98 if (ns->pid_cachep == NULL)
101 err = ns_alloc_inum(&ns->ns);
104 ns->ns.ops = &pidns_operations;
106 kref_init(&ns->kref);
107 ns->level = level;
108 ns->parent = get_pid_ns(parent_pid_ns);
109 ns->user_ns = get_user_ns(user_ns);
110 ns->ucounts = ucounts;
111 ns->pid_allocated = PIDNS_ADDING;
113 return ns;
116 idr_destroy(&ns->idr);
117 kmem_cache_free(pid_ns_cachep, ns);
126 struct pid_namespace *ns = container_of(p, struct pid_namespace, rcu);
128 dec_pid_namespaces(ns->ucounts);
129 put_user_ns(ns->user_ns);
131 kmem_cache_free(pid_ns_cachep, ns);
134 static void destroy_pid_namespace(struct pid_namespace *ns)
136 ns_free_inum(&ns->ns);
138 idr_destroy(&ns->idr);
139 call_rcu(&ns->rcu, delayed_free_pidns);
154 struct pid_namespace *ns;
156 ns = container_of(kref, struct pid_namespace, kref);
157 destroy_pid_namespace(ns);
160 void put_pid_ns(struct pid_namespace *ns)
164 while (ns != &init_pid_ns) {
165 parent = ns->parent;
166 if (!kref_put(&ns->kref, free_pid_ns))
168 ns = parent;
258 * 2) TASK A fork() twice -> TASK B (child reaper for new ns)
294 * Writing directly to ns' last_pid field is OK, since this field
353 static inline struct pid_namespace *to_pid_ns(struct ns_common *ns)
355 return container_of(ns, struct pid_namespace, ns);
360 struct pid_namespace *ns;
363 ns = task_active_pid_ns(task);
364 if (ns)
365 get_pid_ns(ns);
368 return ns ? &ns->ns : NULL;
373 struct pid_namespace *ns = NULL;
377 ns = task->nsproxy->pid_ns_for_children;
378 get_pid_ns(ns);
382 if (ns) {
384 if (!ns->child_reaper) {
385 put_pid_ns(ns);
386 ns = NULL;
391 return ns ? &ns->ns : NULL;
394 static void pidns_put(struct ns_common *ns)
396 put_pid_ns(to_pid_ns(ns));
399 static int pidns_install(struct nsset *nsset, struct ns_common *ns)
403 struct pid_namespace *ancestor, *new = to_pid_ns(ns);
431 static struct ns_common *pidns_get_parent(struct ns_common *ns)
437 pid_ns = p = to_pid_ns(ns)->parent;
446 return &get_pid_ns(pid_ns)->ns;
449 static struct user_namespace *pidns_owner(struct ns_common *ns)
451 return to_pid_ns(ns)->user_ns;