switch the rest of proc_ns_operations to working with &...->ns
[cascardo/linux.git] / ipc / namespace.c
index b54468e..3c1e8d3 100644 (file)
@@ -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->proc_inum);
+       err = proc_alloc_inum(&ns->ns.inum);
        if (err) {
                kfree(ns);
                return ERR_PTR(err);
@@ -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->proc_inum);
+               proc_free_inum(ns->ns.inum);
                kfree(ns);
                return ERR_PTR(err);
        }
@@ -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->proc_inum);
+       proc_free_inum(ns->ns.inum);
        kfree(ns);
 }
 
@@ -149,6 +149,11 @@ void put_ipc_ns(struct ipc_namespace *ns)
        }
 }
 
+static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns)
+{
+       return container_of(ns, struct ipc_namespace, ns);
+}
+
 static void *ipcns_get(struct task_struct *task)
 {
        struct ipc_namespace *ns = NULL;
@@ -160,17 +165,17 @@ static void *ipcns_get(struct task_struct *task)
                ns = get_ipc_ns(nsproxy->ipc_ns);
        task_unlock(task);
 
-       return ns;
+       return ns ? &ns->ns : NULL;
 }
 
 static void ipcns_put(void *ns)
 {
-       return put_ipc_ns(ns);
+       return put_ipc_ns(to_ipc_ns(ns));
 }
 
 static int ipcns_install(struct nsproxy *nsproxy, void *new)
 {
-       struct ipc_namespace *ns = new;
+       struct ipc_namespace *ns = to_ipc_ns(new);
        if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) ||
            !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
                return -EPERM;
@@ -184,9 +189,7 @@ static int ipcns_install(struct nsproxy *nsproxy, void *new)
 
 static unsigned int ipcns_inum(void *vp)
 {
-       struct ipc_namespace *ns = vp;
-
-       return ns->proc_inum;
+       return ((struct ns_common *)vp)->inum;
 }
 
 const struct proc_ns_operations ipcns_operations = {