sysv_sem.c (194894) | sysv_sem.c (194910) |
---|---|
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: head/sys/kern/sysv_sem.c 194894 2009-06-24 20:01:13Z jhb $"); | 40__FBSDID("$FreeBSD: head/sys/kern/sysv_sem.c 194910 2009-06-24 21:10:52Z jhb $"); |
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> --- 1263 unchanged lines hidden (view full) --- 1312 1313 return (SYSCTL_OUT(req, sema, 1314 sizeof(struct semid_kernel) * seminfo.semmni)); 1315} 1316 1317#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ 1318 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) 1319SYSCALL_MODULE_HELPER(semsys); | 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> --- 1263 unchanged lines hidden (view full) --- 1312 1313 return (SYSCTL_OUT(req, sema, 1314 sizeof(struct semid_kernel) * seminfo.semmni)); 1315} 1316 1317#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ 1318 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) 1319SYSCALL_MODULE_HELPER(semsys); |
1320SYSCALL_MODULE_HELPER(freebsd7___semctl); |
|
1320 1321/* XXX casting to (sy_call_t *) is bogus, as usual. */ 1322static sy_call_t *semcalls[] = { | 1321 1322/* XXX casting to (sy_call_t *) is bogus, as usual. */ 1323static sy_call_t *semcalls[] = { |
1323 (sy_call_t *)__semctl, (sy_call_t *)semget, | 1324 (sy_call_t *)freebsd7___semctl, (sy_call_t *)semget, |
1324 (sy_call_t *)semop 1325}; 1326 1327/* 1328 * Entry point for all SEM calls. 1329 */ 1330int 1331semsys(td, uap) --- 12 unchanged lines hidden (view full) --- 1344 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) 1345 return (ENOSYS); 1346 if (uap->which < 0 || 1347 uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) 1348 return (EINVAL); 1349 error = (*semcalls[uap->which])(td, &uap->a2); 1350 return (error); 1351} | 1325 (sy_call_t *)semop 1326}; 1327 1328/* 1329 * Entry point for all SEM calls. 1330 */ 1331int 1332semsys(td, uap) --- 12 unchanged lines hidden (view full) --- 1345 if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) 1346 return (ENOSYS); 1347 if (uap->which < 0 || 1348 uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) 1349 return (EINVAL); 1350 error = (*semcalls[uap->which])(td, &uap->a2); 1351 return (error); 1352} |
1353 1354#define CP(src, dst, fld) do { (dst).fld = (src).fld; } while (0) 1355 1356#ifndef _SYS_SYSPROTO_H_ 1357struct freebsd7___semctl_args { 1358 int semid; 1359 int semnum; 1360 int cmd; 1361 union semun_old *arg; 1362}; 1363#endif 1364int 1365freebsd7___semctl(struct thread *td, struct freebsd7___semctl_args *uap) 1366{ 1367 struct semid_ds_old dsold; 1368 struct semid_ds dsbuf; 1369 union semun_old arg; 1370 union semun semun; 1371 register_t rval; 1372 int error; 1373 1374 switch (uap->cmd) { 1375 case SEM_STAT: 1376 case IPC_SET: 1377 case IPC_STAT: 1378 case GETALL: 1379 case SETVAL: 1380 case SETALL: 1381 error = copyin(uap->arg, &arg, sizeof(arg)); 1382 if (error) 1383 return (error); 1384 break; 1385 } 1386 1387 switch (uap->cmd) { 1388 case SEM_STAT: 1389 case IPC_STAT: 1390 semun.buf = &dsbuf; 1391 break; 1392 case IPC_SET: 1393 error = copyin(arg.buf, &dsold, sizeof(dsold)); 1394 if (error) 1395 return (error); 1396 ipcperm_old2new(&dsold.sem_perm, &dsbuf.sem_perm); 1397 CP(dsold, dsbuf, sem_base); 1398 CP(dsold, dsbuf, sem_nsems); 1399 CP(dsold, dsbuf, sem_otime); 1400 CP(dsold, dsbuf, sem_ctime); 1401 semun.buf = &dsbuf; 1402 break; 1403 case GETALL: 1404 case SETALL: 1405 semun.array = arg.array; 1406 break; 1407 case SETVAL: 1408 semun.val = arg.val; 1409 break; 1410 } 1411 1412 error = kern_semctl(td, uap->semid, uap->semnum, uap->cmd, &semun, 1413 &rval); 1414 if (error) 1415 return (error); 1416 1417 switch (uap->cmd) { 1418 case SEM_STAT: 1419 case IPC_STAT: 1420 bzero(&dsold, sizeof(dsold)); 1421 ipcperm_new2old(&dsbuf.sem_perm, &dsold.sem_perm); 1422 CP(dsbuf, dsold, sem_base); 1423 CP(dsbuf, dsold, sem_nsems); 1424 CP(dsbuf, dsold, sem_otime); 1425 CP(dsbuf, dsold, sem_ctime); 1426 error = copyout(&dsold, arg.buf, sizeof(dsold)); 1427 break; 1428 } 1429 1430 if (error == 0) 1431 td->td_retval[0] = rval; 1432 return (error); 1433} 1434 1435#undef CP 1436 |
|
1352#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 || 1353 COMPAT_FREEBSD7 */ | 1437#endif /* COMPAT_FREEBSD4 || COMPAT_FREEBSD5 || COMPAT_FREEBSD6 || 1438 COMPAT_FREEBSD7 */ |