FreeBSD Bugzilla – Attachment 109267 Details for
Bug 150260
[libc] mmap(2) fails with EPERM (not documented) if read-only shared memory is mmapped with MAP_PRIVATE & PROT_WRITE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
mmap_private.c
mmap_private.c (text/x-csrc; charset=us-ascii), 974 bytes, created by
Alexander Best
on 2010-09-20 17:50:07 UTC
(
hide
)
Description:
mmap_private.c
Filename:
MIME Type:
Creator:
Alexander Best
Created:
2010-09-20 17:50:07 UTC
Size:
974 bytes
patch
obsolete
>#include <sys/types.h> >#include <sys/mman.h> >#include <stdio.h> >#include <string.h> >#include <unistd.h> >#include <fcntl.h> >#include <errno.h> > >int main() >{ > shm_unlink("/myshm"); > int fd = shm_open("/myshm", O_CREAT | O_RDWR, 0644); > if(fd >= 0){ > if(ftruncate(fd, 1000) < 0){ > printf("Error truncating"); > close(fd); > } > else{ > close(fd); > fd = shm_open("/myshm", O_RDONLY/*O_RDWR*/, 0644); > if(fd >= 0){ > void *addr = mmap(0, 1000, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); > if (MAP_FAILED == addr){ > printf("mmap failed, errno: %s", strerror(errno)); > } > else{ > printf("mmap OK"); > munmap(addr, 1000); > } > close(fd); > } > else{ > printf("Error opening shmem"); > } > } > } > else{ > printf("Error creating shmem"); > } > shm_unlink("/myshm"); > return 0; >} > > > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 150260
:
109266
| 109267