Deleted Added
full compact
sysv_shm.c (91406) sysv_shm.c (91703)
1/* $FreeBSD: head/sys/kern/sysv_shm.c 91406 2002-02-27 18:32:23Z jhb $ */
1/* $FreeBSD: head/sys/kern/sysv_shm.c 91703 2002-03-05 18:57:36Z jhb $ */
2/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */
3
4/*
5 * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:

--- 245 unchanged lines hidden (view full) ---

255 struct thread *td;
256 struct shmdt_args *uap;
257{
258 struct proc *p = td->td_proc;
259 struct shmmap_state *shmmap_s;
260 int i;
261 int error = 0;
262
2/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */
3
4/*
5 * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:

--- 245 unchanged lines hidden (view full) ---

255 struct thread *td;
256 struct shmdt_args *uap;
257{
258 struct proc *p = td->td_proc;
259 struct shmmap_state *shmmap_s;
260 int i;
261 int error = 0;
262
263 if (!jail_sysvipc_allowed && jailed(td->td_ucred))
264 return (ENOSYS);
263 mtx_lock(&Giant);
265 mtx_lock(&Giant);
264 if (!jail_sysvipc_allowed && jailed(p->p_ucred)) {
265 error = ENOSYS;
266 goto done2;
267 }
268 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
269 if (shmmap_s == NULL) {
270 error = EINVAL;
271 goto done2;
272 }
273 for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) {
274 if (shmmap_s->shmid != -1 &&
275 shmmap_s->va == (vm_offset_t)uap->shmaddr) {

--- 32 unchanged lines hidden (view full) ---

308 struct shmmap_state *shmmap_s = NULL;
309 struct shm_handle *shm_handle;
310 vm_offset_t attach_va;
311 vm_prot_t prot;
312 vm_size_t size;
313 int rv;
314 int error = 0;
315
266 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
267 if (shmmap_s == NULL) {
268 error = EINVAL;
269 goto done2;
270 }
271 for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) {
272 if (shmmap_s->shmid != -1 &&
273 shmmap_s->va == (vm_offset_t)uap->shmaddr) {

--- 32 unchanged lines hidden (view full) ---

306 struct shmmap_state *shmmap_s = NULL;
307 struct shm_handle *shm_handle;
308 vm_offset_t attach_va;
309 vm_prot_t prot;
310 vm_size_t size;
311 int rv;
312 int error = 0;
313
314 if (!jail_sysvipc_allowed && jailed(td->td_ucred))
315 return (ENOSYS);
316 mtx_lock(&Giant);
316 mtx_lock(&Giant);
317 if (!jail_sysvipc_allowed && jailed(p->p_ucred)) {
318 error = ENOSYS;
319 goto done2;
320 }
321 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
322 if (shmmap_s == NULL) {
323 size = shminfo.shmseg * sizeof(struct shmmap_state);
324 shmmap_s = malloc(size, M_SHM, M_WAITOK);
325 for (i = 0; i < shminfo.shmseg; i++)
326 shmmap_s[i].shmid = -1;
327 p->p_vmspace->vm_shm = (caddr_t)shmmap_s;
328 }

--- 91 unchanged lines hidden (view full) ---

420 struct thread *td;
421 struct oshmctl_args *uap;
422{
423#ifdef COMPAT_43
424 int error = 0;
425 struct shmid_ds *shmseg;
426 struct oshmid_ds outbuf;
427
317 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
318 if (shmmap_s == NULL) {
319 size = shminfo.shmseg * sizeof(struct shmmap_state);
320 shmmap_s = malloc(size, M_SHM, M_WAITOK);
321 for (i = 0; i < shminfo.shmseg; i++)
322 shmmap_s[i].shmid = -1;
323 p->p_vmspace->vm_shm = (caddr_t)shmmap_s;
324 }

--- 91 unchanged lines hidden (view full) ---

416 struct thread *td;
417 struct oshmctl_args *uap;
418{
419#ifdef COMPAT_43
420 int error = 0;
421 struct shmid_ds *shmseg;
422 struct oshmid_ds outbuf;
423
424 if (!jail_sysvipc_allowed && jailed(td->td_ucred))
425 return (ENOSYS);
428 mtx_lock(&Giant);
426 mtx_lock(&Giant);
429 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) {
430 error = ENOSYS;
431 goto done2;
432 }
433 shmseg = shm_find_segment_by_shmid(uap->shmid);
434 if (shmseg == NULL) {
435 error = EINVAL;
436 goto done2;
437 }
438 switch (uap->cmd) {
439 case IPC_STAT:
440 error = ipcperm(td, &shmseg->shm_perm, IPC_R);

--- 40 unchanged lines hidden (view full) ---

481shmctl(td, uap)
482 struct thread *td;
483 struct shmctl_args *uap;
484{
485 int error = 0;
486 struct shmid_ds inbuf;
487 struct shmid_ds *shmseg;
488
427 shmseg = shm_find_segment_by_shmid(uap->shmid);
428 if (shmseg == NULL) {
429 error = EINVAL;
430 goto done2;
431 }
432 switch (uap->cmd) {
433 case IPC_STAT:
434 error = ipcperm(td, &shmseg->shm_perm, IPC_R);

--- 40 unchanged lines hidden (view full) ---

475shmctl(td, uap)
476 struct thread *td;
477 struct shmctl_args *uap;
478{
479 int error = 0;
480 struct shmid_ds inbuf;
481 struct shmid_ds *shmseg;
482
483 if (!jail_sysvipc_allowed && jailed(td->td_ucred))
484 return (ENOSYS);
489 mtx_lock(&Giant);
485 mtx_lock(&Giant);
490 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) {
491 error = ENOSYS;
492 goto done2;
493 }
494 switch (uap->cmd) {
495 case IPC_INFO:
496 error = copyout( (caddr_t)&shminfo, uap->buf, sizeof( shminfo ) );
497 if (error)
498 goto done2;
499 td->td_retval[0] = shmalloced;
500 goto done2;
501 case SHM_INFO: {

--- 199 unchanged lines hidden (view full) ---

701int
702shmget(td, uap)
703 struct thread *td;
704 struct shmget_args *uap;
705{
706 int segnum, mode;
707 int error;
708
486 switch (uap->cmd) {
487 case IPC_INFO:
488 error = copyout( (caddr_t)&shminfo, uap->buf, sizeof( shminfo ) );
489 if (error)
490 goto done2;
491 td->td_retval[0] = shmalloced;
492 goto done2;
493 case SHM_INFO: {

--- 199 unchanged lines hidden (view full) ---

693int
694shmget(td, uap)
695 struct thread *td;
696 struct shmget_args *uap;
697{
698 int segnum, mode;
699 int error;
700
701 if (!jail_sysvipc_allowed && jailed(td->td_ucred))
702 return (ENOSYS);
709 mtx_lock(&Giant);
703 mtx_lock(&Giant);
710 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) {
711 error = ENOSYS;
712 goto done2;
713 }
714 mode = uap->shmflg & ACCESSPERMS;
715 if (uap->key != IPC_PRIVATE) {
716 again:
717 segnum = shm_find_segment_by_key(uap->key);
718 if (segnum >= 0) {
719 error = shmget_existing(td, uap, mode, segnum);
720 if (error == EAGAIN)
721 goto again;

--- 21 unchanged lines hidden (view full) ---

743 u_int which;
744 int a2;
745 int a3;
746 int a4;
747 } */ *uap;
748{
749 int error;
750
704 mode = uap->shmflg & ACCESSPERMS;
705 if (uap->key != IPC_PRIVATE) {
706 again:
707 segnum = shm_find_segment_by_key(uap->key);
708 if (segnum >= 0) {
709 error = shmget_existing(td, uap, mode, segnum);
710 if (error == EAGAIN)
711 goto again;

--- 21 unchanged lines hidden (view full) ---

733 u_int which;
734 int a2;
735 int a3;
736 int a4;
737 } */ *uap;
738{
739 int error;
740
741 if (!jail_sysvipc_allowed && jailed(td->td_ucred))
742 return (ENOSYS);
743 if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0]))
744 return (EINVAL);
751 mtx_lock(&Giant);
745 mtx_lock(&Giant);
752 if (!jail_sysvipc_allowed && jailed(td->td_proc->p_ucred)) {
753 error = ENOSYS;
754 goto done2;
755 }
756 if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) {
757 error = EINVAL;
758 goto done2;
759 }
760 error = (*shmcalls[uap->which])(td, &uap->a2);
746 error = (*shmcalls[uap->which])(td, &uap->a2);
761done2:
762 mtx_unlock(&Giant);
763 return (error);
764}
765
766static void
767shmfork_myhook(p1, p2)
768 struct proc *p1, *p2;
769{

--- 136 unchanged lines hidden ---
747 mtx_unlock(&Giant);
748 return (error);
749}
750
751static void
752shmfork_myhook(p1, p2)
753 struct proc *p1, *p2;
754{

--- 136 unchanged lines hidden ---