sysv_shm.c (61081) | sysv_shm.c (68024) |
---|---|
1/* $FreeBSD: head/sys/kern/sysv_shm.c 61081 2000-05-29 22:40:54Z dillon $ */ | 1/* $FreeBSD: head/sys/kern/sysv_shm.c 68024 2000-10-31 01:34:00Z rwatson $ */ |
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: --- 31 unchanged lines hidden (view full) --- 41#include <sys/kernel.h> 42#include <sys/sysctl.h> 43#include <sys/shm.h> 44#include <sys/proc.h> 45#include <sys/malloc.h> 46#include <sys/mman.h> 47#include <sys/stat.h> 48#include <sys/sysent.h> | 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: --- 31 unchanged lines hidden (view full) --- 41#include <sys/kernel.h> 42#include <sys/sysctl.h> 43#include <sys/shm.h> 44#include <sys/proc.h> 45#include <sys/malloc.h> 46#include <sys/mman.h> 47#include <sys/stat.h> 48#include <sys/sysent.h> |
49#include <sys/jail.h> |
|
49 50#include <vm/vm.h> 51#include <vm/vm_param.h> 52#include <sys/lock.h> 53#include <vm/pmap.h> 54#include <vm/vm_object.h> 55#include <vm/vm_map.h> 56#include <vm/vm_page.h> --- 161 unchanged lines hidden (view full) --- 218int 219shmdt(p, uap) 220 struct proc *p; 221 struct shmdt_args *uap; 222{ 223 struct shmmap_state *shmmap_s; 224 int i; 225 | 50 51#include <vm/vm.h> 52#include <vm/vm_param.h> 53#include <sys/lock.h> 54#include <vm/pmap.h> 55#include <vm/vm_object.h> 56#include <vm/vm_map.h> 57#include <vm/vm_page.h> --- 161 unchanged lines hidden (view full) --- 219int 220shmdt(p, uap) 221 struct proc *p; 222 struct shmdt_args *uap; 223{ 224 struct shmmap_state *shmmap_s; 225 int i; 226 |
227 if (!jail_sysvipc_allowed && p->p_prison != NULL) 228 return (ENOSYS); 229 |
|
226 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; 227 if (shmmap_s == NULL) 228 return EINVAL; 229 for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) 230 if (shmmap_s->shmid != -1 && 231 shmmap_s->va == (vm_offset_t)uap->shmaddr) 232 break; 233 if (i == shminfo.shmseg) --- 18 unchanged lines hidden (view full) --- 252 struct shmid_ds *shmseg; 253 struct shmmap_state *shmmap_s = NULL; 254 struct shm_handle *shm_handle; 255 vm_offset_t attach_va; 256 vm_prot_t prot; 257 vm_size_t size; 258 int rv; 259 | 230 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; 231 if (shmmap_s == NULL) 232 return EINVAL; 233 for (i = 0; i < shminfo.shmseg; i++, shmmap_s++) 234 if (shmmap_s->shmid != -1 && 235 shmmap_s->va == (vm_offset_t)uap->shmaddr) 236 break; 237 if (i == shminfo.shmseg) --- 18 unchanged lines hidden (view full) --- 256 struct shmid_ds *shmseg; 257 struct shmmap_state *shmmap_s = NULL; 258 struct shm_handle *shm_handle; 259 vm_offset_t attach_va; 260 vm_prot_t prot; 261 vm_size_t size; 262 int rv; 263 |
264 if (!jail_sysvipc_allowed && p->p_prison != NULL) 265 return (ENOSYS); 266 |
|
260 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; 261 if (shmmap_s == NULL) { 262 size = shminfo.shmseg * sizeof(struct shmmap_state); 263 shmmap_s = malloc(size, M_SHM, M_WAITOK); 264 for (i = 0; i < shminfo.shmseg; i++) 265 shmmap_s[i].shmid = -1; 266 p->p_vmspace->vm_shm = (caddr_t)shmmap_s; 267 } --- 75 unchanged lines hidden (view full) --- 343 struct proc *p; 344 struct oshmctl_args *uap; 345{ 346#ifdef COMPAT_43 347 int error; 348 struct shmid_ds *shmseg; 349 struct oshmid_ds outbuf; 350 | 267 shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm; 268 if (shmmap_s == NULL) { 269 size = shminfo.shmseg * sizeof(struct shmmap_state); 270 shmmap_s = malloc(size, M_SHM, M_WAITOK); 271 for (i = 0; i < shminfo.shmseg; i++) 272 shmmap_s[i].shmid = -1; 273 p->p_vmspace->vm_shm = (caddr_t)shmmap_s; 274 } --- 75 unchanged lines hidden (view full) --- 350 struct proc *p; 351 struct oshmctl_args *uap; 352{ 353#ifdef COMPAT_43 354 int error; 355 struct shmid_ds *shmseg; 356 struct oshmid_ds outbuf; 357 |
358 if (!jail_sysvipc_allowed && p->p_prison != NULL) 359 return (ENOSYS); 360 |
|
351 shmseg = shm_find_segment_by_shmid(uap->shmid); 352 if (shmseg == NULL) 353 return EINVAL; 354 switch (uap->cmd) { 355 case IPC_STAT: 356 error = ipcperm(p, &shmseg->shm_perm, IPC_R); 357 if (error) 358 return error; --- 32 unchanged lines hidden (view full) --- 391shmctl(p, uap) 392 struct proc *p; 393 struct shmctl_args *uap; 394{ 395 int error; 396 struct shmid_ds inbuf; 397 struct shmid_ds *shmseg; 398 | 361 shmseg = shm_find_segment_by_shmid(uap->shmid); 362 if (shmseg == NULL) 363 return EINVAL; 364 switch (uap->cmd) { 365 case IPC_STAT: 366 error = ipcperm(p, &shmseg->shm_perm, IPC_R); 367 if (error) 368 return error; --- 32 unchanged lines hidden (view full) --- 401shmctl(p, uap) 402 struct proc *p; 403 struct shmctl_args *uap; 404{ 405 int error; 406 struct shmid_ds inbuf; 407 struct shmid_ds *shmseg; 408 |
409 if (!jail_sysvipc_allowed && p->p_prison != NULL) 410 return (ENOSYS); 411 |
|
399 shmseg = shm_find_segment_by_shmid(uap->shmid); 400 if (shmseg == NULL) 401 return EINVAL; 402 switch (uap->cmd) { 403 case IPC_STAT: 404 error = ipcperm(p, &shmseg->shm_perm, IPC_R); 405 if (error) 406 return error; --- 160 unchanged lines hidden (view full) --- 567 568int 569shmget(p, uap) 570 struct proc *p; 571 struct shmget_args *uap; 572{ 573 int segnum, mode, error; 574 | 412 shmseg = shm_find_segment_by_shmid(uap->shmid); 413 if (shmseg == NULL) 414 return EINVAL; 415 switch (uap->cmd) { 416 case IPC_STAT: 417 error = ipcperm(p, &shmseg->shm_perm, IPC_R); 418 if (error) 419 return error; --- 160 unchanged lines hidden (view full) --- 580 581int 582shmget(p, uap) 583 struct proc *p; 584 struct shmget_args *uap; 585{ 586 int segnum, mode, error; 587 |
588 if (!jail_sysvipc_allowed && p->p_prison != NULL) 589 return (ENOSYS); 590 |
|
575 mode = uap->shmflg & ACCESSPERMS; 576 if (uap->key != IPC_PRIVATE) { 577 again: 578 segnum = shm_find_segment_by_key(uap->key); 579 if (segnum >= 0) { 580 error = shmget_existing(p, uap, mode, segnum); 581 if (error == EAGAIN) 582 goto again; --- 12 unchanged lines hidden (view full) --- 595 struct shmsys_args /* { 596 u_int which; 597 int a2; 598 int a3; 599 int a4; 600 } */ *uap; 601{ 602 | 591 mode = uap->shmflg & ACCESSPERMS; 592 if (uap->key != IPC_PRIVATE) { 593 again: 594 segnum = shm_find_segment_by_key(uap->key); 595 if (segnum >= 0) { 596 error = shmget_existing(p, uap, mode, segnum); 597 if (error == EAGAIN) 598 goto again; --- 12 unchanged lines hidden (view full) --- 611 struct shmsys_args /* { 612 u_int which; 613 int a2; 614 int a3; 615 int a4; 616 } */ *uap; 617{ 618 |
619 if (!jail_sysvipc_allowed && p->p_prison != NULL) 620 return (ENOSYS); 621 |
|
603 if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) 604 return EINVAL; 605 return ((*shmcalls[uap->which])(p, &uap->a2)); 606} 607 608void 609shmfork(p1, p2) 610 struct proc *p1, *p2; --- 71 unchanged lines hidden --- | 622 if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) 623 return EINVAL; 624 return ((*shmcalls[uap->which])(p, &uap->a2)); 625} 626 627void 628shmfork(p1, p2) 629 struct proc *p1, *p2; --- 71 unchanged lines hidden --- |