1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <OS.h>
4
main(int count,char ** args)5 int main(int count, char **args) {
6
7 sem_id cursorSem = atoi(args[2]);
8 area_id appArea = atoi(args[1]);
9 void *appBuffer;
10 area_id newArea;
11
12 acquire_sem(cursorSem);
13
14 newArea = clone_area("isClone", &appBuffer, B_ANY_ADDRESS, B_READ_AREA|B_WRITE_AREA, appArea);
15 if (newArea > 0) {
16 int fd = open ("/tmp/input_area.bin", O_WRONLY | O_CREAT | O_TRUNC, 0644);
17 if (fd >= 0) {
18 write (fd, appBuffer, 0x1000);
19 close (fd);
20 }
21 printf("success when writing area %ld\n", appArea);
22
23 delete_area(newArea);
24 }
25
26 return 0;
27 }
28