#include #include #include #include #include int main(int argc, char **argv) { int fd = open(argv[1], O_RDWR | O_CREAT, (mode_t)0600); const char *text = "hello"; size_t textsize = strlen(text) + 1; char *map; lseek(fd, textsize-1, SEEK_SET); write(fd, "", 1); map = mmap(0, textsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); printf("address is 0x%x\n", (unsigned long)map); memcpy(map, text, strlen(text)); //while(1); msync(map, textsize, MS_SYNC); munmap(map, textsize); close(fd); return 0; }