Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84643
b: refs/heads/master
c: 4b9fcb0
h: refs/heads/master
i:
  84641: 184f015
  84639: 7d3a65a
v: v3
  • Loading branch information
Pierre Peiffer authored and Linus Torvalds committed Feb 8, 2008
1 parent abbcf4b commit db5a083
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b2d75cddc83a349ef5633f609b9734b6b957f90f
refs/heads/master: 4b9fcb0ec60584d639ad105c42b75a3447071e47
38 changes: 16 additions & 22 deletions trunk/ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,8 @@ static unsigned long copy_semid_to_user(void __user *buf, struct semid64_ds *in,
}
}

static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum,
int cmd, int version, union semun arg)
static int semctl_nolock(struct ipc_namespace *ns, int semid,
int cmd, int version, union semun arg)
{
int err = -EINVAL;
struct sem_array *sma;
Expand Down Expand Up @@ -657,14 +657,23 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum,
return -EFAULT;
return (max_id < 0) ? 0: max_id;
}
case IPC_STAT:
case SEM_STAT:
{
struct semid64_ds tbuf;
int id;

sma = sem_lock(ns, semid);
if (IS_ERR(sma))
return PTR_ERR(sma);
if (cmd == SEM_STAT) {
sma = sem_lock(ns, semid);
if (IS_ERR(sma))
return PTR_ERR(sma);
id = sma->sem_perm.id;
} else {
sma = sem_lock_check(ns, semid);
if (IS_ERR(sma))
return PTR_ERR(sma);
id = 0;
}

err = -EACCES;
if (ipcperms (&sma->sem_perm, S_IRUGO))
Expand All @@ -674,8 +683,6 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid, int semnum,
if (err)
goto out_unlock;

id = sma->sem_perm.id;

memset(&tbuf, 0, sizeof(tbuf));

kernel_to_ipc64_perm(&sma->sem_perm, &tbuf.sem_perm);
Expand Down Expand Up @@ -810,19 +817,6 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
err = 0;
goto out_unlock;
}
case IPC_STAT:
{
struct semid64_ds tbuf;
memset(&tbuf,0,sizeof(tbuf));
kernel_to_ipc64_perm(&sma->sem_perm, &tbuf.sem_perm);
tbuf.sem_otime = sma->sem_otime;
tbuf.sem_ctime = sma->sem_ctime;
tbuf.sem_nsems = sma->sem_nsems;
sem_unlock(sma);
if (copy_semid_to_user (arg.buf, &tbuf, version))
return -EFAULT;
return 0;
}
/* GETVAL, GETPID, GETNCTN, GETZCNT, SETVAL: fall-through */
}
err = -EINVAL;
Expand Down Expand Up @@ -989,15 +983,15 @@ asmlinkage long sys_semctl (int semid, int semnum, int cmd, union semun arg)
switch(cmd) {
case IPC_INFO:
case SEM_INFO:
case IPC_STAT:
case SEM_STAT:
err = semctl_nolock(ns,semid,semnum,cmd,version,arg);
err = semctl_nolock(ns, semid, cmd, version, arg);
return err;
case GETALL:
case GETVAL:
case GETPID:
case GETNCNT:
case GETZCNT:
case IPC_STAT:
case SETVAL:
case SETALL:
err = semctl_main(ns,semid,semnum,cmd,version,arg);
Expand Down

0 comments on commit db5a083

Please sign in to comment.