pid namespaces: changes to show virtual ids to user
[powerpc.git] / ipc / sem.c
index 21b3289..64ff426 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -75,7 +75,6 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/time.h>
-#include <linux/smp_lock.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/audit.h>
@@ -122,7 +121,7 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it);
 #define sc_semopm      sem_ctls[2]
 #define sc_semmni      sem_ctls[3]
 
-static void __ipc_init __sem_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids)
+static void __sem_init_ns(struct ipc_namespace *ns, struct ipc_ids *ids)
 {
        ns->ids[IPC_SEM_IDS] = ids;
        ns->sc_semmsl = SEMMSL;
@@ -133,7 +132,6 @@ static void __ipc_init __sem_init_ns(struct ipc_namespace *ns, struct ipc_ids *i
        ipc_init_ids(ids, ns->sc_semmni);
 }
 
-#ifdef CONFIG_IPC_NS
 int sem_init_ns(struct ipc_namespace *ns)
 {
        struct ipc_ids *ids;
@@ -165,7 +163,6 @@ void sem_exit_ns(struct ipc_namespace *ns)
        kfree(ns->ids[IPC_SEM_IDS]);
        ns->ids[IPC_SEM_IDS] = NULL;
 }
-#endif
 
 void __init sem_init (void)
 {
@@ -798,7 +795,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                for (un = sma->undo; un; un = un->id_next)
                        un->semadj[semnum] = 0;
                curr->semval = val;
-               curr->sempid = current->tgid;
+               curr->sempid = task_tgid_vnr(current);
                sma->sem_ctime = get_seconds();
                /* maybe some queued-up processes were waiting for this */
                update_queue(sma);
@@ -859,7 +856,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid, int semnum,
 {
        struct sem_array *sma;
        int err;
-       struct sem_setbuf setbuf;
+       struct sem_setbuf uninitialized_var(setbuf);
        struct kern_ipc_perm *ipcp;
 
        if(cmd == IPC_SET) {
@@ -1070,14 +1067,13 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid)
        ipc_rcu_getref(sma);
        sem_unlock(sma);
 
-       new = (struct sem_undo *) kmalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
+       new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
        if (!new) {
                ipc_lock_by_ptr(&sma->sem_perm);
                ipc_rcu_putref(sma);
                sem_unlock(sma);
                return ERR_PTR(-ENOMEM);
        }
-       memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
        new->semadj = (short *) &new[1];
        new->semid = semid;
 
@@ -1200,7 +1196,7 @@ retry_undos:
        if (error)
                goto out_unlock_free;
 
-       error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
+       error = try_atomic_semop (sma, sops, nsops, un, task_tgid_vnr(current));
        if (error <= 0) {
                if (alter && error == 0)
                        update_queue (sma);
@@ -1215,7 +1211,7 @@ retry_undos:
        queue.sops = sops;
        queue.nsops = nsops;
        queue.undo = un;
-       queue.pid = current->tgid;
+       queue.pid = task_tgid_vnr(current);
        queue.id = semid;
        queue.alter = alter;
        if (alter)
@@ -1386,7 +1382,7 @@ found:
                                        semaphore->semval = 0;
                                if (semaphore->semval > SEMVMX)
                                        semaphore->semval = SEMVMX;
-                               semaphore->sempid = current->tgid;
+                               semaphore->sempid = task_tgid_vnr(current);
                        }
                }
                sma->sem_otime = get_seconds();