add USL's copyright notice
[unix-history] / usr / src / sys / kern / sysv_shm.c
index 4a6c03d..e0ff2e9 100644 (file)
@@ -2,16 +2,21 @@
  * Copyright (c) 1988 University of Utah.
  * Copyright (c) 1990, 1993
  *     The Regents of the University of California.  All rights reserved.
  * Copyright (c) 1988 University of Utah.
  * Copyright (c) 1990, 1993
  *     The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
  *
  * This code is derived from software contributed to Berkeley by
  * the Systems Programming Group of the University of Utah Computer
  *
  * This code is derived from software contributed to Berkeley by
  * the Systems Programming Group of the University of Utah Computer
- * Science Department. Originally from University of Wisconsin.
+ * Science Department.  Originally from the University of Wisconsin.
  *
  *
- * %sccs.include.redist.c%
+ * %sccs.include.proprietary.c%
  *
  * from: Utah $Hdr: uipc_shm.c 1.11 92/04/23$
  *
  *
  * from: Utah $Hdr: uipc_shm.c 1.11 92/04/23$
  *
- *     @(#)sysv_shm.c  8.1 (Berkeley) %G%
+ *     @(#)sysv_shm.c  8.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -29,6 +34,7 @@
 #include <sys/shm.h>
 #include <sys/malloc.h>
 #include <sys/mman.h>
 #include <sys/shm.h>
 #include <sys/malloc.h>
 #include <sys/mman.h>
+#include <sys/stat.h>
 
 #include <vm/vm.h>
 #include <vm/vm_kern.h>
 
 #include <vm/vm.h>
 #include <vm/vm_kern.h>
@@ -64,7 +70,7 @@ shminit()
        vm_offset_t whocares1, whocares2;
 
        shm_map = kmem_suballoc(kernel_map, &whocares1, &whocares2,
        vm_offset_t whocares1, whocares2;
 
        shm_map = kmem_suballoc(kernel_map, &whocares1, &whocares2,
-                               shminfo.shmall * NBPG, FALSE);
+                               shminfo.shmall * NBPG, TRUE);
        if (shminfo.shmmni > SHMMMNI)
                shminfo.shmmni = SHMMMNI;
        for (i = 0; i < shminfo.shmmni; i++) {
        if (shminfo.shmmni > SHMMMNI)
                shminfo.shmmni = SHMMMNI;
        for (i = 0; i < shminfo.shmmni; i++) {
@@ -163,7 +169,7 @@ shmget(p, uap, retval)
                shmtot += size;
                shp->shm_perm.cuid = shp->shm_perm.uid = cred->cr_uid;
                shp->shm_perm.cgid = shp->shm_perm.gid = cred->cr_gid;
                shmtot += size;
                shp->shm_perm.cuid = shp->shm_perm.uid = cred->cr_uid;
                shp->shm_perm.cgid = shp->shm_perm.gid = cred->cr_gid;
-               shp->shm_perm.mode = SHM_ALLOC | (uap->shmflg&0777);
+               shp->shm_perm.mode = SHM_ALLOC | (uap->shmflg & ACCESSPERMS);
                shp->shm_segsz = uap->size;
                shp->shm_cpid = p->p_pid;
                shp->shm_lpid = shp->shm_nattch = 0;
                shp->shm_segsz = uap->size;
                shp->shm_cpid = p->p_pid;
                shp->shm_lpid = shp->shm_nattch = 0;
@@ -174,7 +180,8 @@ shmget(p, uap, retval)
                /* XXX: probably not the right thing to do */
                if (shp->shm_perm.mode & SHM_DEST)
                        return (EBUSY);
                /* XXX: probably not the right thing to do */
                if (shp->shm_perm.mode & SHM_DEST)
                        return (EBUSY);
-               if (error = ipcaccess(&shp->shm_perm, uap->shmflg&0777, cred))
+               if (error = ipcaccess(&shp->shm_perm, uap->shmflg & ACCESSPERMS,
+                           cred))
                        return (error);
                if (uap->size && uap->size > shp->shm_segsz)
                        return (EINVAL);
                        return (error);
                if (uap->size && uap->size > shp->shm_segsz)
                        return (EINVAL);
@@ -221,8 +228,8 @@ shmctl(p, uap, retval)
                        return (error);
                shp->shm_perm.uid = sbuf.shm_perm.uid;
                shp->shm_perm.gid = sbuf.shm_perm.gid;
                        return (error);
                shp->shm_perm.uid = sbuf.shm_perm.uid;
                shp->shm_perm.gid = sbuf.shm_perm.gid;
-               shp->shm_perm.mode = (shp->shm_perm.mode & ~0777)
-                       | (sbuf.shm_perm.mode & 0777);
+               shp->shm_perm.mode = (shp->shm_perm.mode & ~ACCESSPERMS)
+                       | (sbuf.shm_perm.mode & ACCESSPERMS);
                shp->shm_ctime = time.tv_sec;
                break;
 
                shp->shm_ctime = time.tv_sec;
                break;
 
@@ -347,9 +354,10 @@ shmdt(p, uap, retval)
                    shmd->shmd_uva == (vm_offset_t)uap->shmaddr)
                        break;
        if (i == shminfo.shmseg)
                    shmd->shmd_uva == (vm_offset_t)uap->shmaddr)
                        break;
        if (i == shminfo.shmseg)
-               return(EINVAL);
+               return (EINVAL);
        shmufree(p, shmd);
        shmsegs[shmd->shmd_id % SHMMMNI].shm_lpid = p->p_pid;
        shmufree(p, shmd);
        shmsegs[shmd->shmd_id % SHMMMNI].shm_lpid = p->p_pid;
+       return (0);
 }
 
 shmfork(p1, p2, isvfork)
 }
 
 shmfork(p1, p2, isvfork)