3 Copies one file to another, using mmap. */
10 main (int argc, char *argv[])
13 mapid_t in_map, out_map;
14 void *in_data = (void *) 0x10000000;
15 void *out_data = (void *) 0x20000000;
20 printf ("usage: cp OLD NEW\n");
24 /* Open input file. */
25 in_fd = open (argv[1]);
28 printf ("%s: open failed\n", argv[1]);
31 size = filesize (in_fd);
33 /* Create and open output file. */
34 if (!create (argv[2], size))
36 printf ("%s: create failed\n", argv[2]);
39 out_fd = open (argv[2]);
42 printf ("%s: open failed\n", argv[2]);
47 in_map = mmap (in_fd, in_data);
48 if (in_map == MAP_FAILED)
50 printf ("%s: mmap failed\n", argv[1]);
53 out_map = mmap (out_fd, out_data);
54 if (out_map == MAP_FAILED)
56 printf ("%s: mmap failed\n", argv[2]);
61 memcpy (out_data, in_data, size);
63 /* Unmap files (optional). */