Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/sys/kern Pullup rev 1.78 (requested by jdolecek in tick...



details:   https://anonhg.NetBSD.org/src/rev/0c11e2097bb6
branches:  netbsd-2-0
changeset: 562742:0c11e2097bb6
user:      jmc <jmc%NetBSD.org@localhost>
date:      Mon Oct 04 05:19:09 2004 +0000

description:
Pullup rev 1.78 (requested by jdolecek in ticket #884)

Fix linux handling of SysV-style shared memory. Fixed Linux VMware display
problems.

diffstat:

 sys/kern/sysv_shm.c |  62 +++++++++++++++++++---------------------------------
 1 files changed, 23 insertions(+), 39 deletions(-)

diffs (169 lines):

diff -r b0eff6fbe2d6 -r 0c11e2097bb6 sys/kern/sysv_shm.c
--- a/sys/kern/sysv_shm.c       Mon Oct 04 05:19:07 2004 +0000
+++ b/sys/kern/sysv_shm.c       Mon Oct 04 05:19:09 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysv_shm.c,v 1.76 2004/03/23 13:22:33 junyoung Exp $   */
+/*     $NetBSD: sysv_shm.c,v 1.76.2.1 2004/10/04 05:19:09 jmc Exp $    */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.76 2004/03/23 13:22:33 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.76.2.1 2004/10/04 05:19:09 jmc Exp $");
 
 #define SYSVSHM
 
@@ -88,7 +88,7 @@
 #include <uvm/uvm_extern.h>
 #include <uvm/uvm_object.h>
 
-struct shmid_ds *shm_find_segment_by_shmid(int, int);
+struct shmid_ds *shm_find_segment_by_shmid(int);
 
 static MALLOC_DEFINE(M_SHM, "shm", "SVID compatible shared memory segments");
 
@@ -108,6 +108,7 @@
 #define        SHMSEG_REMOVED          0x0400
 #define        SHMSEG_ALLOCATED        0x0800
 #define        SHMSEG_WANTED           0x1000
+#define        SHMSEG_RMLINGER         0x2000
 
 static int     shm_last_free, shm_nused, shm_committed;
 struct shmid_ds *shmsegs;
@@ -155,9 +156,8 @@
 }
 
 struct shmid_ds *
-shm_find_segment_by_shmid(shmid, findremoved)
+shm_find_segment_by_shmid(shmid)
        int shmid;
-       int findremoved;
 {
        int segnum;
        struct shmid_ds *shmseg;
@@ -168,7 +168,7 @@
        shmseg = &shmsegs[segnum];
        if ((shmseg->shm_perm.mode & SHMSEG_ALLOCATED) == 0)
                return NULL;
-       if (!findremoved && ((shmseg->shm_perm.mode & SHMSEG_REMOVED) != 0))
+       if ((shmseg->shm_perm.mode & (SHMSEG_REMOVED|SHMSEG_RMLINGER)) == SHMSEG_REMOVED)
                return NULL;
        if (shmseg->shm_perm._seq != IPCID_TO_SEQ(shmid))
                return NULL;
@@ -324,28 +324,8 @@
                syscallarg(const void *) shmaddr;
                syscallarg(int) shmflg;
        } */ *uap = v;
+       int error, flags;
        struct proc *p = l->l_proc;
-       vaddr_t attach_va;
-       int error;
-
-       error = shmat1(p, SCARG(uap, shmid), SCARG(uap, shmaddr),
-           SCARG(uap, shmflg), &attach_va, 0);
-       if (error != 0)
-               return error;
-       retval[0] = attach_va;
-       return 0;
-}
-
-int
-shmat1(p, shmid, shmaddr, shmflg, attachp, findremoved)
-       struct proc *p;
-       int shmid;
-       const void *shmaddr;
-       int shmflg;
-       vaddr_t *attachp;
-       int findremoved;
-{
-       int error, flags;
        struct ucred *cred = p->p_ucred;
        struct shmid_ds *shmseg;
        struct shmmap_state *shmmap_s;
@@ -355,11 +335,11 @@
        vsize_t size;
        struct shmmap_entry *shmmap_se;
 
-       shmseg = shm_find_segment_by_shmid(shmid, findremoved);
+       shmseg = shm_find_segment_by_shmid(SCARG(uap, shmid));
        if (shmseg == NULL)
                return EINVAL;
        error = ipcperm(cred, &shmseg->shm_perm,
-                   (shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);
+                   (SCARG(uap, shmflg) & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);
        if (error)
                return error;
 
@@ -369,16 +349,16 @@
 
        size = (shmseg->shm_segsz + PGOFSET) & ~PGOFSET;
        prot = VM_PROT_READ;
-       if ((shmflg & SHM_RDONLY) == 0)
+       if ((SCARG(uap, shmflg) & SHM_RDONLY) == 0)
                prot |= VM_PROT_WRITE;
        flags = MAP_ANON | MAP_SHARED;
-       if (shmaddr) {
+       if (SCARG(uap, shmaddr)) {
                flags |= MAP_FIXED;
-               if (shmflg & SHM_RND)
+               if (SCARG(uap, shmflg) & SHM_RND)
                        attach_va =
-                           (vaddr_t)shmaddr & ~(SHMLBA-1);
-               else if (((vaddr_t)shmaddr & (SHMLBA-1)) == 0)
-                       attach_va = (vaddr_t)shmaddr;
+                           (vaddr_t)SCARG(uap, shmaddr) & ~(SHMLBA-1);
+               else if (((vaddr_t)SCARG(uap, shmaddr) & (SHMLBA-1)) == 0)
+                       attach_va = (vaddr_t)SCARG(uap, shmaddr);
                else
                        return EINVAL;
        } else {
@@ -396,7 +376,7 @@
        }
        shmmap_se = pool_get(&shmmap_entry_pool, PR_WAITOK);
        shmmap_se->va = attach_va;
-       shmmap_se->shmid = shmid;
+       shmmap_se->shmid = SCARG(uap, shmid);
        shmmap_s = shmmap_getprivate(p);
 #ifdef SHMDEBUG
        printf("shmat: vm %p: add %d @%lx\n", p->p_vmspace, shmid, attach_va);
@@ -406,7 +386,8 @@
        shmseg->shm_lpid = p->p_pid;
        shmseg->shm_atime = time.tv_sec;
        shmseg->shm_nattch++;
-       *attachp = attach_va;
+
+       retval[0] = attach_va;
        return 0;
 }
 
@@ -453,7 +434,7 @@
        struct shmid_ds *shmseg;
        int error = 0;
 
-       shmseg = shm_find_segment_by_shmid(shmid, 0);
+       shmseg = shm_find_segment_by_shmid(shmid);
        if (shmseg == NULL)
                return EINVAL;
        switch (cmd) {
@@ -584,7 +565,7 @@
        shmseg->shm_perm.cuid = shmseg->shm_perm.uid = cred->cr_uid;
        shmseg->shm_perm.cgid = shmseg->shm_perm.gid = cred->cr_gid;
        shmseg->shm_perm.mode = (shmseg->shm_perm.mode & SHMSEG_WANTED) |
-           (mode & ACCESSPERMS) | SHMSEG_ALLOCATED;
+           (mode & (ACCESSPERMS|SHMSEG_RMLINGER)) | SHMSEG_ALLOCATED;
        shmseg->shm_segsz = SCARG(uap, size);
        shmseg->shm_cpid = p->p_pid;
        shmseg->shm_lpid = shmseg->shm_nattch = 0;
@@ -620,6 +601,9 @@
        int segnum, mode, error;
 
        mode = SCARG(uap, shmflg) & ACCESSPERMS;
+       if (SCARG(uap, shmflg) & _SHM_RMLINGER)
+               mode |= SHMSEG_RMLINGER;
+
        if (SCARG(uap, key) != IPC_PRIVATE) {
        again:
                segnum = shm_find_segment_by_key(SCARG(uap, key));



Home | Main Index | Thread Index | Old Index