From: Ben Gras Date: Fri, 15 Jul 2011 16:10:50 +0000 (+0200) Subject: rename mmap MAP_SHARED to MAP_IPC_SHARED X-Git-Tag: v3.2.0~455 X-Git-Url: http://zhaoyanbai.com/repos/icons/debian/static/man.7.txt?a=commitdiff_plain;h=85f6d866e63ee404856effae339e54c5690778a2;p=minix.git rename mmap MAP_SHARED to MAP_IPC_SHARED . MAP_SHARED was used to implement sysv shared memory . used to signal shareable memory region to VM . assumptions about this situation break when processes use MAP_SHARED for its normal, standardised meaning --- diff --git a/include/sys/mman.h b/include/sys/mman.h index 3bfa64c7d..5040ff7e4 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -13,7 +13,6 @@ #define PROT_EXEC 0x04 /* pages can be executed */ /* flags argument for mmap() */ -#define MAP_SHARED 0x0001 /* share changes */ #define MAP_PRIVATE 0x0002 /* changes are private */ #define MAP_ANON 0x0004 /* anonymous memory */ #define MAP_PREALLOC 0x0008 /* not on-demand */ @@ -21,6 +20,7 @@ #define MAP_LOWER16M 0x0020 /* physically below 16MB */ #define MAP_ALIGN64K 0x0040 /* physically aligned at 64kB */ #define MAP_LOWER1M 0x0080 /* physically below 16MB */ +#define MAP_IPC_SHARED 0x0100 /* used to implement shared memory */ /* mmap() error return */ #define MAP_FAILED ((void *)-1) diff --git a/nbsd_include/sys/mman.h b/nbsd_include/sys/mman.h index 75860eaa4..8a03de7d0 100644 --- a/nbsd_include/sys/mman.h +++ b/nbsd_include/sys/mman.h @@ -35,7 +35,9 @@ typedef __off_t off_t; /* file offset */ * Flags contain sharing type and options. * Sharing types; choose one. */ +#ifndef __minix #define MAP_SHARED 0x0001 /* share changes */ +#endif #define MAP_PRIVATE 0x0002 /* changes are private */ /* @@ -52,6 +54,7 @@ typedef __off_t off_t; /* file offset */ #define MAP_ALIGN64K 0x0040 /* physically aligned at 64kB */ #define MAP_LOWER1M 0x0080 /* physically below 16MB */ #define MAP_ALIGNMENT_64KB MAP_ALIGN64K +#define MAP_IPC_SHARED 0x0100 /* share changes */ /* * Error indicator returned by mmap(2) diff --git a/servers/ipc/shm.c b/servers/ipc/shm.c index d94d641b3..b90bf73cb 100644 --- a/servers/ipc/shm.c +++ b/servers/ipc/shm.c @@ -74,7 +74,7 @@ PUBLIC int do_shmget(message *m) memset(shm, 0, sizeof(struct shm_struct)); shm->page = (vir_bytes) mmap(0, size, PROT_READ|PROT_WRITE, - MAP_CONTIG|MAP_PREALLOC|MAP_ANON|MAP_SHARED, + MAP_CONTIG|MAP_PREALLOC|MAP_ANON|MAP_IPC_SHARED, -1, 0); if (shm->page == (vir_bytes) MAP_FAILED) return ENOMEM; diff --git a/servers/is/dmp_vm.c b/servers/is/dmp_vm.c index 02f02ac0b..13ef4ca87 100644 --- a/servers/is/dmp_vm.c +++ b/servers/is/dmp_vm.c @@ -56,7 +56,7 @@ PRIVATE void print_region(struct vm_region_info *vri, int *n) (vri->vri_prot & PROT_READ) ? 'r' : '-', (vri->vri_prot & PROT_WRITE) ? 'w' : '-', (vri->vri_prot & PROT_EXEC) ? 'x' : '-', - (vri->vri_flags & MAP_SHARED) ? 's' : 'p', + (vri->vri_flags & MAP_IPC_SHARED) ? 's' : 'p', vri->vri_length / 1024L); (*n)++; } diff --git a/servers/procfs/pid.c b/servers/procfs/pid.c index 581768678..e460c1058 100644 --- a/servers/procfs/pid.c +++ b/servers/procfs/pid.c @@ -368,7 +368,7 @@ PRIVATE int dump_regions(int slot) (vri[i].vri_prot & PROT_READ) ? 'r' : '-', (vri[i].vri_prot & PROT_WRITE) ? 'w' : '-', (vri[i].vri_prot & PROT_EXEC) ? 'x' : '-', - (vri[i].vri_flags & MAP_SHARED) ? 's' : 'p'); + (vri[i].vri_flags & MAP_IPC_SHARED) ? 's' : 'p'); count++; } diff --git a/servers/vm/mmap.c b/servers/vm/mmap.c index 4c67ed989..ce238887e 100644 --- a/servers/vm/mmap.c +++ b/servers/vm/mmap.c @@ -68,7 +68,14 @@ PUBLIC int do_mmap(message *m) if(m->VMM_FLAGS & MAP_LOWER16M) vrflags |= VR_LOWER16MB; if(m->VMM_FLAGS & MAP_LOWER1M) vrflags |= VR_LOWER1MB; if(m->VMM_FLAGS & MAP_ALIGN64K) vrflags |= VR_PHYS64K; - if(m->VMM_FLAGS & MAP_SHARED) vrflags |= VR_SHARED; + if(m->VMM_FLAGS & MAP_IPC_SHARED) { + vrflags |= VR_SHARED; + /* Shared memory has to be preallocated. */ + if(m->VMM_FLAGS & (MAP_PREALLOC|MAP_ANON) != + (MAP_PREALLOC|MAP_ANON)) { + return EINVAL; + } + } if(m->VMM_FLAGS & MAP_CONTIG) vrflags |= VR_CONTIG; if(len % VM_PAGE_SIZE) diff --git a/servers/vm/region.c b/servers/vm/region.c index 081ab1ca4..c44062f85 100644 --- a/servers/vm/region.c +++ b/servers/vm/region.c @@ -1999,7 +1999,7 @@ PUBLIC int get_region_info(struct vmproc *vmp, struct vm_region_info *vri, if (!(vr->flags & VR_WRITABLE)) vri->vri_prot &= ~PROT_WRITE; - vri->vri_flags = (vr->flags & VR_SHARED) ? MAP_SHARED : 0; + vri->vri_flags = (vr->flags & VR_SHARED) ? MAP_IPC_SHARED : 0; next = vr->vaddr + vr->length; region_incr_iter(&v_iter);