sysv_sem.c (91417) | sysv_sem.c (91703) |
---|---|
1/* $FreeBSD: head/sys/kern/sysv_sem.c 91417 2002-02-27 19:12:14Z jhb $ */ | 1/* $FreeBSD: head/sys/kern/sysv_sem.c 91703 2002-03-05 18:57:36Z jhb $ */ |
2 3/* 4 * Implementation of SVID semaphores 5 * 6 * Author: Daniel Boulet 7 * 8 * This software is provided ``AS IS'' without any warranties of any kind. 9 */ --- 246 unchanged lines hidden (view full) --- 256 int a2; 257 int a3; 258 int a4; 259 int a5; 260 } */ *uap; 261{ 262 int error; 263 | 2 3/* 4 * Implementation of SVID semaphores 5 * 6 * Author: Daniel Boulet 7 * 8 * This software is provided ``AS IS'' without any warranties of any kind. 9 */ --- 246 unchanged lines hidden (view full) --- 256 int a2; 257 int a3; 258 int a4; 259 int a5; 260 } */ *uap; 261{ 262 int error; 263 |
264 if (!jail_sysvipc_allowed && jailed(td->td_ucred)) 265 return (ENOSYS); 266 if (uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) 267 return (EINVAL); |
|
264 mtx_lock(&Giant); | 268 mtx_lock(&Giant); |
265 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { 266 error = ENOSYS; 267 goto done2; 268 } 269 if (uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) { 270 error = EINVAL; 271 goto done2; 272 } | |
273 error = (*semcalls[uap->which])(td, &uap->a2); | 269 error = (*semcalls[uap->which])(td, &uap->a2); |
274done2: | |
275 mtx_unlock(&Giant); 276 return (error); 277} 278 279/* 280 * Allocate a new sem_undo structure for a process 281 * (returns ptr to structure or NULL if no more room) 282 */ --- 197 unchanged lines hidden (view full) --- 480 int i, rval, error; 481 struct semid_ds sbuf; 482 register struct semid_ds *semaptr; 483 u_short usval; 484 485#ifdef SEM_DEBUG 486 printf("call to semctl(%d, %d, %d, 0x%x)\n", semid, semnum, cmd, arg); 487#endif | 270 mtx_unlock(&Giant); 271 return (error); 272} 273 274/* 275 * Allocate a new sem_undo structure for a process 276 * (returns ptr to structure or NULL if no more room) 277 */ --- 197 unchanged lines hidden (view full) --- 475 int i, rval, error; 476 struct semid_ds sbuf; 477 register struct semid_ds *semaptr; 478 u_short usval; 479 480#ifdef SEM_DEBUG 481 printf("call to semctl(%d, %d, %d, 0x%x)\n", semid, semnum, cmd, arg); 482#endif |
488 mtx_lock(&Giant); 489 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { 490 error = ENOSYS; 491 goto done2; 492 } | 483 if (!jail_sysvipc_allowed && jailed(td->td_ucred)) 484 return (ENOSYS); |
493 | 485 |
486 mtx_lock(&Giant); |
|
494 switch(cmd) { 495 case SEM_STAT: 496 if (semid < 0 || semid >= seminfo.semmsl) 497 UGAR(EINVAL); 498 semaptr = &sema[semid]; 499 if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 ) 500 UGAR(EINVAL); 501 if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) --- 186 unchanged lines hidden (view full) --- 688semget(td, uap) 689 struct thread *td; 690 register struct semget_args *uap; 691{ 692 int semid, error = 0; 693 int key = uap->key; 694 int nsems = uap->nsems; 695 int semflg = uap->semflg; | 487 switch(cmd) { 488 case SEM_STAT: 489 if (semid < 0 || semid >= seminfo.semmsl) 490 UGAR(EINVAL); 491 semaptr = &sema[semid]; 492 if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 ) 493 UGAR(EINVAL); 494 if ((error = ipcperm(td, &semaptr->sem_perm, IPC_R))) --- 186 unchanged lines hidden (view full) --- 681semget(td, uap) 682 struct thread *td; 683 register struct semget_args *uap; 684{ 685 int semid, error = 0; 686 int key = uap->key; 687 int nsems = uap->nsems; 688 int semflg = uap->semflg; |
696 struct ucred *cred = td->td_proc->p_ucred; | 689 struct ucred *cred = td->td_ucred; |
697 698#ifdef SEM_DEBUG 699 printf("semget(0x%x, %d, 0%o)\n", key, nsems, semflg); 700#endif | 690 691#ifdef SEM_DEBUG 692 printf("semget(0x%x, %d, 0%o)\n", key, nsems, semflg); 693#endif |
701 mtx_lock(&Giant); 702 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { 703 error = ENOSYS; 704 goto done2; 705 } | 694 if (!jail_sysvipc_allowed && jailed(td->td_ucred)) 695 return (ENOSYS); |
706 | 696 |
697 mtx_lock(&Giant); |
|
707 if (key != IPC_PRIVATE) { 708 for (semid = 0; semid < seminfo.semmni; semid++) { 709 if ((sema[semid].sem_perm.mode & SEM_ALLOC) && 710 sema[semid].sem_perm.key == key) 711 break; 712 } 713 if (semid < seminfo.semmni) { 714#ifdef SEM_DEBUG --- 114 unchanged lines hidden (view full) --- 829 struct sem_undo *suptr; 830 int i, j, error; 831 int do_wakeup, do_undos; 832 833#ifdef SEM_DEBUG 834 printf("call to semop(%d, 0x%x, %u)\n", semid, sops, nsops); 835#endif 836 | 698 if (key != IPC_PRIVATE) { 699 for (semid = 0; semid < seminfo.semmni; semid++) { 700 if ((sema[semid].sem_perm.mode & SEM_ALLOC) && 701 sema[semid].sem_perm.key == key) 702 break; 703 } 704 if (semid < seminfo.semmni) { 705#ifdef SEM_DEBUG --- 114 unchanged lines hidden (view full) --- 820 struct sem_undo *suptr; 821 int i, j, error; 822 int do_wakeup, do_undos; 823 824#ifdef SEM_DEBUG 825 printf("call to semop(%d, 0x%x, %u)\n", semid, sops, nsops); 826#endif 827 |
837 mtx_lock(&Giant); 838 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) { 839 error = ENOSYS; 840 goto done2; 841 } | 828 if (!jail_sysvipc_allowed && jailed(td->td_ucred)) 829 return (ENOSYS); |
842 | 830 |
831 mtx_lock(&Giant); |
|
843 semid = IPCID_TO_IX(semid); /* Convert back to zero origin */ 844 845 if (semid < 0 || semid >= seminfo.semmsl) { 846 error = EINVAL; 847 goto done2; 848 } 849 850 semaptr = &sema[semid]; --- 354 unchanged lines hidden --- | 832 semid = IPCID_TO_IX(semid); /* Convert back to zero origin */ 833 834 if (semid < 0 || semid >= seminfo.semmsl) { 835 error = EINVAL; 836 goto done2; 837 } 838 839 semaptr = &sema[semid]; --- 354 unchanged lines hidden --- |