#include <linux/mount.h>
#include <linux/seq_file.h>
#include <linux/poll.h>
+#include <linux/ns_common.h>
struct mnt_namespace {
atomic_t count;
- unsigned int proc_inum;
+ struct ns_common ns;
struct mount * root;
struct list_head list;
struct user_namespace *user_ns;
static void free_mnt_ns(struct mnt_namespace *ns)
{
- proc_free_inum(ns->proc_inum);
+ proc_free_inum(ns->ns.inum);
put_user_ns(ns->user_ns);
kfree(ns);
}
new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
if (!new_ns)
return ERR_PTR(-ENOMEM);
- ret = proc_alloc_inum(&new_ns->proc_inum);
+ ret = proc_alloc_inum(&new_ns->ns.inum);
if (ret) {
kfree(new_ns);
return ERR_PTR(ret);
static unsigned int mntns_inum(void *ns)
{
struct mnt_namespace *mnt_ns = ns;
- return mnt_ns->proc_inum;
+ return mnt_ns->ns.inum;
}
const struct proc_ns_operations mntns_operations = {
#include <linux/rwsem.h>
#include <linux/notifier.h>
#include <linux/nsproxy.h>
+#include <linux/ns_common.h>
/*
* ipc namespace events
/* user_ns which owns the ipc ns */
struct user_namespace *user_ns;
- unsigned int proc_inum;
+ struct ns_common ns;
};
extern struct ipc_namespace init_ipc_ns;
--- /dev/null
+#ifndef _LINUX_NS_COMMON_H
+#define _LINUX_NS_COMMON_H
+
+struct ns_common {
+ unsigned int inum;
+};
+
+#endif
#include <linux/threads.h>
#include <linux/nsproxy.h>
#include <linux/kref.h>
+#include <linux/ns_common.h>
struct pidmap {
atomic_t nr_free;
kgid_t pid_gid;
int hide_pid;
int reboot; /* group exit code if this pidns was rebooted */
- unsigned int proc_inum;
+ struct ns_common ns;
};
extern struct pid_namespace init_pid_ns;
#include <linux/kref.h>
#include <linux/nsproxy.h>
+#include <linux/ns_common.h>
#include <linux/sched.h>
#include <linux/err.h>
int level;
kuid_t owner;
kgid_t group;
- unsigned int proc_inum;
+ struct ns_common ns;
/* Register of per-UID persistent keyrings for this namespace */
#ifdef CONFIG_PERSISTENT_KEYRINGS
#include <linux/sched.h>
#include <linux/kref.h>
#include <linux/nsproxy.h>
+#include <linux/ns_common.h>
#include <linux/err.h>
#include <uapi/linux/utsname.h>
struct kref kref;
struct new_utsname name;
struct user_namespace *user_ns;
- unsigned int proc_inum;
+ struct ns_common ns;
};
extern struct uts_namespace init_uts_ns;
#endif
#include <net/netns/nftables.h>
#include <net/netns/xfrm.h>
+#include <linux/ns_common.h>
struct user_namespace;
struct proc_dir_entry;
struct user_namespace *user_ns; /* Owning user namespace */
- unsigned int proc_inum;
+ struct ns_common ns;
struct proc_dir_entry *proc_net;
struct proc_dir_entry *proc_net_stat;
.domainname = UTS_DOMAINNAME,
},
.user_ns = &init_user_ns,
- .proc_inum = PROC_UTS_INIT_INO,
+ .ns.inum = PROC_UTS_INIT_INO,
};
EXPORT_SYMBOL_GPL(init_uts_ns);
struct ipc_namespace init_ipc_ns = {
.count = ATOMIC_INIT(1),
.user_ns = &init_user_ns,
- .proc_inum = PROC_IPC_INIT_INO,
+ .ns.inum = PROC_IPC_INIT_INO,
};
atomic_t nr_ipc_ns = ATOMIC_INIT(1);
if (ns == NULL)
return ERR_PTR(-ENOMEM);
- err = proc_alloc_inum(&ns->proc_inum);
+ err = proc_alloc_inum(&ns->ns.inum);
if (err) {
kfree(ns);
return ERR_PTR(err);
atomic_set(&ns->count, 1);
err = mq_init_ns(ns);
if (err) {
- proc_free_inum(ns->proc_inum);
+ proc_free_inum(ns->ns.inum);
kfree(ns);
return ERR_PTR(err);
}
*/
ipcns_notify(IPCNS_REMOVED);
put_user_ns(ns->user_ns);
- proc_free_inum(ns->proc_inum);
+ proc_free_inum(ns->ns.inum);
kfree(ns);
}
{
struct ipc_namespace *ns = vp;
- return ns->proc_inum;
+ return ns->ns.inum;
}
const struct proc_ns_operations ipcns_operations = {
.level = 0,
.child_reaper = &init_task,
.user_ns = &init_user_ns,
- .proc_inum = PROC_PID_INIT_INO,
+ .ns.inum = PROC_PID_INIT_INO,
};
EXPORT_SYMBOL_GPL(init_pid_ns);
if (ns->pid_cachep == NULL)
goto out_free_map;
- err = proc_alloc_inum(&ns->proc_inum);
+ err = proc_alloc_inum(&ns->ns.inum);
if (err)
goto out_free_map;
{
int i;
- proc_free_inum(ns->proc_inum);
+ proc_free_inum(ns->ns.inum);
for (i = 0; i < PIDMAP_ENTRIES; i++)
kfree(ns->pidmap[i].page);
put_user_ns(ns->user_ns);
static unsigned int pidns_inum(void *ns)
{
struct pid_namespace *pid_ns = ns;
- return pid_ns->proc_inum;
+ return pid_ns->ns.inum;
}
const struct proc_ns_operations pidns_operations = {
.count = ATOMIC_INIT(3),
.owner = GLOBAL_ROOT_UID,
.group = GLOBAL_ROOT_GID,
- .proc_inum = PROC_USER_INIT_INO,
+ .ns.inum = PROC_USER_INIT_INO,
#ifdef CONFIG_PERSISTENT_KEYRINGS
.persistent_keyring_register_sem =
__RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem),
if (!ns)
return -ENOMEM;
- ret = proc_alloc_inum(&ns->proc_inum);
+ ret = proc_alloc_inum(&ns->ns.inum);
if (ret) {
kmem_cache_free(user_ns_cachep, ns);
return ret;
#ifdef CONFIG_PERSISTENT_KEYRINGS
key_put(ns->persistent_keyring_register);
#endif
- proc_free_inum(ns->proc_inum);
+ proc_free_inum(ns->ns.inum);
kmem_cache_free(user_ns_cachep, ns);
ns = parent;
} while (atomic_dec_and_test(&parent->count));
static unsigned int userns_inum(void *ns)
{
struct user_namespace *user_ns = ns;
- return user_ns->proc_inum;
+ return user_ns->ns.inum;
}
const struct proc_ns_operations userns_operations = {
if (!ns)
return ERR_PTR(-ENOMEM);
- err = proc_alloc_inum(&ns->proc_inum);
+ err = proc_alloc_inum(&ns->ns.inum);
if (err) {
kfree(ns);
return ERR_PTR(err);
ns = container_of(kref, struct uts_namespace, kref);
put_user_ns(ns->user_ns);
- proc_free_inum(ns->proc_inum);
+ proc_free_inum(ns->ns.inum);
kfree(ns);
}
{
struct uts_namespace *ns = vp;
- return ns->proc_inum;
+ return ns->ns.inum;
}
const struct proc_ns_operations utsns_operations = {
static __net_init int net_ns_net_init(struct net *net)
{
- return proc_alloc_inum(&net->proc_inum);
+ return proc_alloc_inum(&net->ns.inum);
}
static __net_exit void net_ns_net_exit(struct net *net)
{
- proc_free_inum(net->proc_inum);
+ proc_free_inum(net->ns.inum);
}
static struct pernet_operations __net_initdata net_ns_ops = {
static unsigned int netns_inum(void *ns)
{
struct net *net = ns;
- return net->proc_inum;
+ return net->ns.inum;
}
const struct proc_ns_operations netns_operations = {