1
0
mirror of https://github.com/ioacademy-jikim/device_driver synced 2025-06-07 16:06:08 +00:00
device_driver/03_day/jni/mmap_app.c
ioacademy-jikim e92d98c6d0 first sample
2015-08-19 19:26:23 +09:00

22 lines
321 B
C

#if 1
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
int main()
{
int fd;
char *p;
fd = open("/dev/mydev", O_RDWR );
p = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
strcpy( p , "hello world\n");
printf("%s\n", p );
munmap(p, 4096);
close(fd);
return 0;
}
#endif