sysv_sem.c (256281) | sysv_sem.c (284665) |
---|---|
1/*- 2 * Implementation of SVID semaphores 3 * 4 * Author: Daniel Boulet 5 * 6 * This software is provided ``AS IS'' without any warranties of any kind. 7 */ 8/*- --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 39#include <sys/cdefs.h> | 1/*- 2 * Implementation of SVID semaphores 3 * 4 * Author: Daniel Boulet 5 * 6 * This software is provided ``AS IS'' without any warranties of any kind. 7 */ 8/*- --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 39#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: stable/10/sys/kern/sysv_sem.c 225617 2011-09-16 13:58:51Z kmacy $"); | 40__FBSDID("$FreeBSD: stable/10/sys/kern/sysv_sem.c 284665 2015-06-21 06:28:26Z trasz $"); |
41 42#include "opt_compat.h" 43#include "opt_sysvipc.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysproto.h> 48#include <sys/eventhandler.h> --- 871 unchanged lines hidden (view full) --- 920 break; 921 } 922 if (semid == seminfo.semmni) { 923 DPRINTF(("no more semid_kernel's available\n")); 924 error = ENOSPC; 925 goto done2; 926 } 927#ifdef RACCT | 41 42#include "opt_compat.h" 43#include "opt_sysvipc.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/sysproto.h> 48#include <sys/eventhandler.h> --- 871 unchanged lines hidden (view full) --- 920 break; 921 } 922 if (semid == seminfo.semmni) { 923 DPRINTF(("no more semid_kernel's available\n")); 924 error = ENOSPC; 925 goto done2; 926 } 927#ifdef RACCT |
928 PROC_LOCK(td->td_proc); 929 error = racct_add(td->td_proc, RACCT_NSEM, nsems); 930 PROC_UNLOCK(td->td_proc); 931 if (error != 0) { 932 error = ENOSPC; 933 goto done2; | 928 if (racct_enable) { 929 PROC_LOCK(td->td_proc); 930 error = racct_add(td->td_proc, RACCT_NSEM, nsems); 931 PROC_UNLOCK(td->td_proc); 932 if (error != 0) { 933 error = ENOSPC; 934 goto done2; 935 } |
934 } 935#endif 936 DPRINTF(("semid %d is available\n", semid)); 937 mtx_lock(&sema_mtx[semid]); 938 KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, 939 ("Lost semaphore %d", semid)); 940 sema[semid].u.sem_perm.key = key; 941 sema[semid].u.sem_perm.cuid = cred->cr_uid; --- 72 unchanged lines hidden (view full) --- 1014 if (nsops <= SMALL_SOPS) 1015 sops = small_sops; 1016 else if (nsops > seminfo.semopm) { 1017 DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm, 1018 nsops)); 1019 return (E2BIG); 1020 } else { 1021#ifdef RACCT | 936 } 937#endif 938 DPRINTF(("semid %d is available\n", semid)); 939 mtx_lock(&sema_mtx[semid]); 940 KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, 941 ("Lost semaphore %d", semid)); 942 sema[semid].u.sem_perm.key = key; 943 sema[semid].u.sem_perm.cuid = cred->cr_uid; --- 72 unchanged lines hidden (view full) --- 1016 if (nsops <= SMALL_SOPS) 1017 sops = small_sops; 1018 else if (nsops > seminfo.semopm) { 1019 DPRINTF(("too many sops (max=%d, nsops=%d)\n", seminfo.semopm, 1020 nsops)); 1021 return (E2BIG); 1022 } else { 1023#ifdef RACCT |
1022 PROC_LOCK(td->td_proc); 1023 if (nsops > racct_get_available(td->td_proc, RACCT_NSEMOP)) { | 1024 if (racct_enable) { 1025 PROC_LOCK(td->td_proc); 1026 if (nsops > 1027 racct_get_available(td->td_proc, RACCT_NSEMOP)) { 1028 PROC_UNLOCK(td->td_proc); 1029 return (E2BIG); 1030 } |
1024 PROC_UNLOCK(td->td_proc); | 1031 PROC_UNLOCK(td->td_proc); |
1025 return (E2BIG); | |
1026 } | 1032 } |
1027 PROC_UNLOCK(td->td_proc); | |
1028#endif 1029 1030 sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK); 1031 } 1032 if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) { 1033 DPRINTF(("error = %d from copyin(%p, %p, %d)\n", error, 1034 uap->sops, sops, nsops * sizeof(sops[0]))); 1035 if (sops != small_sops) --- 631 unchanged lines hidden --- | 1033#endif 1034 1035 sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK); 1036 } 1037 if ((error = copyin(uap->sops, sops, nsops * sizeof(sops[0]))) != 0) { 1038 DPRINTF(("error = %d from copyin(%p, %p, %d)\n", error, 1039 uap->sops, sops, nsops * sizeof(sops[0]))); 1040 if (sops != small_sops) --- 631 unchanged lines hidden --- |