Skip to content

Commit

Permalink
new helpers: ns_alloc_inum/ns_free_inum
Browse files Browse the repository at this point in the history
take struct ns_common *, for now simply wrappers around proc_{alloc,free}_inum()

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Dec 4, 2014
1 parent 6496452 commit 6344c43
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@ long do_mount(const char *dev_name, const char __user *dir_name,

static void free_mnt_ns(struct mnt_namespace *ns)
{
proc_free_inum(ns->ns.inum);
ns_free_inum(&ns->ns);
put_user_ns(ns->user_ns);
kfree(ns);
}
Expand All @@ -2667,7 +2667,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
if (!new_ns)
return ERR_PTR(-ENOMEM);
ret = proc_alloc_inum(&new_ns->ns.inum);
ret = ns_alloc_inum(&new_ns->ns);
if (ret) {
kfree(new_ns);
return ERR_PTR(ret);
Expand Down
3 changes: 3 additions & 0 deletions include/linux/proc_ns.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ static inline bool proc_ns_inode(struct inode *inode) { return false; }

#endif /* CONFIG_PROC_FS */

#define ns_alloc_inum(ns) proc_alloc_inum(&(ns)->inum)
#define ns_free_inum(ns) proc_free_inum((ns)->inum)

#endif /* _LINUX_PROC_NS_H */
6 changes: 3 additions & 3 deletions ipc/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
if (ns == NULL)
return ERR_PTR(-ENOMEM);

err = proc_alloc_inum(&ns->ns.inum);
err = ns_alloc_inum(&ns->ns);
if (err) {
kfree(ns);
return ERR_PTR(err);
Expand All @@ -35,7 +35,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
atomic_set(&ns->count, 1);
err = mq_init_ns(ns);
if (err) {
proc_free_inum(ns->ns.inum);
ns_free_inum(&ns->ns);
kfree(ns);
return ERR_PTR(err);
}
Expand Down Expand Up @@ -119,7 +119,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)
*/
ipcns_notify(IPCNS_REMOVED);
put_user_ns(ns->user_ns);
proc_free_inum(ns->ns.inum);
ns_free_inum(&ns->ns);
kfree(ns);
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/pid_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
if (ns->pid_cachep == NULL)
goto out_free_map;

err = proc_alloc_inum(&ns->ns.inum);
err = ns_alloc_inum(&ns->ns);
if (err)
goto out_free_map;

Expand Down Expand Up @@ -142,7 +142,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns)
{
int i;

proc_free_inum(ns->ns.inum);
ns_free_inum(&ns->ns);
for (i = 0; i < PIDMAP_ENTRIES; i++)
kfree(ns->pidmap[i].page);
put_user_ns(ns->user_ns);
Expand Down
4 changes: 2 additions & 2 deletions kernel/user_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int create_user_ns(struct cred *new)
if (!ns)
return -ENOMEM;

ret = proc_alloc_inum(&ns->ns.inum);
ret = ns_alloc_inum(&ns->ns);
if (ret) {
kmem_cache_free(user_ns_cachep, ns);
return ret;
Expand Down Expand Up @@ -136,7 +136,7 @@ void free_user_ns(struct user_namespace *ns)
#ifdef CONFIG_PERSISTENT_KEYRINGS
key_put(ns->persistent_keyring_register);
#endif
proc_free_inum(ns->ns.inum);
ns_free_inum(&ns->ns);
kmem_cache_free(user_ns_cachep, ns);
ns = parent;
} while (atomic_dec_and_test(&parent->count));
Expand Down
4 changes: 2 additions & 2 deletions kernel/utsname.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
if (!ns)
return ERR_PTR(-ENOMEM);

err = proc_alloc_inum(&ns->ns.inum);
err = ns_alloc_inum(&ns->ns);
if (err) {
kfree(ns);
return ERR_PTR(err);
Expand Down Expand Up @@ -84,7 +84,7 @@ void free_uts_ns(struct kref *kref)

ns = container_of(kref, struct uts_namespace, kref);
put_user_ns(ns->user_ns);
proc_free_inum(ns->ns.inum);
ns_free_inum(&ns->ns);
kfree(ns);
}

Expand Down
4 changes: 2 additions & 2 deletions net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid);

static __net_init int net_ns_net_init(struct net *net)
{
return proc_alloc_inum(&net->ns.inum);
return ns_alloc_inum(&net->ns);
}

static __net_exit void net_ns_net_exit(struct net *net)
{
proc_free_inum(net->ns.inum);
ns_free_inum(&net->ns);
}

static struct pernet_operations __net_initdata net_ns_ops = {
Expand Down

0 comments on commit 6344c43

Please sign in to comment.