move_pages: just use calloc
[trinity.git] / syscalls / remap_file_pages.c
blobaed6937749ae7715770cfe467500f67d69e0ef31
1 /*
2 * SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
3 unsigned long, prot, unsigned long, pgoff, unsigned long, flags)
4 */
5 #include <stdlib.h>
6 #include <asm/mman.h>
7 #include "arch.h"
8 #include "maps.h"
9 #include "random.h"
10 #include "sanitise.h"
11 #include "shm.h"
13 static void sanitise_remap_file_pages(int childno)
15 struct map *map;
16 size_t size;
18 map = common_set_mmap_ptr_len(childno);
20 /* We just want to remap a part of the mapping. */
21 size = rand() % map->size;
22 shm->syscall[childno].a2 = size;
24 /* "The prot argument must be specified as 0" */
25 shm->syscall[childno].a3 = 0;
27 /* Pick a random pgoff. */
28 shm->syscall[childno].a4 = rand() & (size / page_size);
31 struct syscallentry syscall_remap_file_pages = {
32 .name = "remap_file_pages",
33 .num_args = 5,
34 .arg1name = "start",
35 .arg1type = ARG_MMAP,
36 .arg2name = "size",
37 .arg3name = "prot",
38 .arg4name = "pgoff",
39 .arg5name = "flags",
40 .arg5type = ARG_LIST,
41 .arg5list = {
42 .num = 1,
43 .values = { MAP_NONBLOCK },
45 .group = GROUP_VM,
46 .sanitise = sanitise_remap_file_pages,