FreeBSD Bugzilla – Attachment 215581 Details for
Bug 247276
[fusefs]: Lockup when using mmap w/ direct_io
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
example mmap usage
mmap-write.c (text/plain), 604 bytes, created by
trapexit
on 2020-06-15 12:33:53 UTC
(
hide
)
Description:
example mmap usage
Filename:
MIME Type:
Creator:
trapexit
Created:
2020-06-15 12:33:53 UTC
Size:
604 bytes
patch
obsolete
>#include <fcntl.h> >#include <stdio.h> >#include <stdlib.h> >#include <sys/mman.h> >#include <unistd.h> >#include <sys/types.h> > >int >main(void) >{ > int fd; > unsigned char *mem; > > fd = open("test.img",O_RDWR|O_CREAT); > if(fd == -1) > { > perror("open"); > return 1; > } > > ftruncate(fd,1024*1024); > > mem = mmap(NULL,1024*1024,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); > if(mem == NULL) > { > perror("mmap"); > return 1; > } > > for(int i = 0; i < 1024*1024; i++) > { > mem[i] = i; > printf("%x %x\n",i,mem[i]); > } > > munmap(mem,1024*1024); > > close(fd); > > 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 247276
: 215581