Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/mman.h>
- char BUF[100];
- int plik1, plik2;
- char plik_wym[1000];
- char lena[30];
- struct stat buffer;
- char *ptr;
- int main()
- {
- if (fork() == 0) //dziecko
- {
- execlp("display","display","plik_wym", NULL);
- }
- while(1)
- {
- printf("Podaj nazwe pliku: \n");
- scanf("%s", lena);
- plik1=open(lena, O_RDONLY);
- plik2=open(plik_wym, O_WRONLY);
- stat("plik_wym", &buffer);
- ftruncate(plik2, buffer.st_size);
- ptr=mmap(0,buffer.st_size, PROT_WRITE, MAP_SHARED, plik1, 0);
- read(plik2, ptr ,buffer.st_size);
- msync(ptr,buffer.st_size,MS_SYNC);
- munmap(ptr, buffer.st_size);
- close(plik1);
- close(plik2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement