Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sysv_sem.c
Show First 20 Lines • Show All 909 Lines • ▼ Show 20 Lines | for (semid = 0; semid < seminfo.semmni; semid++) { | ||||
break; | break; | ||||
} | } | ||||
if (semid == seminfo.semmni) { | if (semid == seminfo.semmni) { | ||||
DPRINTF(("no more semid_kernel's available\n")); | DPRINTF(("no more semid_kernel's available\n")); | ||||
error = ENOSPC; | error = ENOSPC; | ||||
goto done2; | goto done2; | ||||
} | } | ||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | |||||
PROC_LOCK(td->td_proc); | PROC_LOCK(td->td_proc); | ||||
error = racct_add(td->td_proc, RACCT_NSEM, nsems); | error = racct_add(td->td_proc, RACCT_NSEM, nsems); | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
if (error != 0) { | if (error != 0) { | ||||
error = ENOSPC; | error = ENOSPC; | ||||
goto done2; | goto done2; | ||||
} | } | ||||
} | |||||
#endif | #endif | ||||
DPRINTF(("semid %d is available\n", semid)); | DPRINTF(("semid %d is available\n", semid)); | ||||
mtx_lock(&sema_mtx[semid]); | mtx_lock(&sema_mtx[semid]); | ||||
KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, | KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, | ||||
("Lost semaphore %d", semid)); | ("Lost semaphore %d", semid)); | ||||
sema[semid].u.sem_perm.key = key; | sema[semid].u.sem_perm.key = key; | ||||
sema[semid].u.sem_perm.cuid = cred->cr_uid; | sema[semid].u.sem_perm.cuid = cred->cr_uid; | ||||
sema[semid].u.sem_perm.uid = cred->cr_uid; | sema[semid].u.sem_perm.uid = cred->cr_uid; | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | #endif | ||||
if (nsops <= SMALL_SOPS) | if (nsops <= SMALL_SOPS) | ||||
sops = small_sops; | sops = small_sops; | ||||
else if (nsops > seminfo.semopm) { | else if (nsops > seminfo.semopm) { | ||||
DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm, | DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm, | ||||
nsops)); | nsops)); | ||||
return (E2BIG); | return (E2BIG); | ||||
} else { | } else { | ||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | |||||
PROC_LOCK(td->td_proc); | PROC_LOCK(td->td_proc); | ||||
if (nsops > racct_get_available(td->td_proc, RACCT_NSEMOP)) { | if (nsops > | ||||
racct_get_available(td->td_proc, RACCT_NSEMOP)) { | |||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
return (E2BIG); | return (E2BIG); | ||||
} | } | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
} | |||||
#endif | #endif | ||||
sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK); | sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK); | ||||
} | } | ||||
if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) { | if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) { | ||||
DPRINTF(("error = %d from copyin(%p, %p, %d)\n", error, | DPRINTF(("error = %d from copyin(%p, %p, %d)\n", error, | ||||
uap->sops, sops, nsops * sizeof(sops[0]))); | uap->sops, sops, nsops * sizeof(sops[0]))); | ||||
if (sops != small_sops) | if (sops != small_sops) | ||||
▲ Show 20 Lines • Show All 631 Lines • Show Last 20 Lines |