merge newfstat variants
[trinity.git] / syscalls / mbind.c
blobaec047244911670451b1172054ad61dc13e03b63
1 /*
2 * SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len,
3 unsigned long, mode, unsigned long __user *, nmask,
4 unsigned long, maxnode, unsigned, flags)
5 */
7 #include <linux/mempolicy.h>
8 #include "arch.h"
9 #include "maps.h"
10 #include "random.h"
11 #include "sanitise.h"
12 #include "shm.h"
13 #include "utils.h" // page_size
15 #define MPOL_F_STATIC_NODES (1 << 15)
16 #define MPOL_F_RELATIVE_NODES (1 << 14)
18 static void sanitise_mbind(int childno)
20 unsigned long maxnode;
22 (void) common_set_mmap_ptr_len(childno);
24 retry_maxnode:
25 shm->a5[childno] &= ~((page_size * 8) - 1);
27 maxnode = shm->a5[childno];
29 if (maxnode < 2 || maxnode > (page_size * 8)) {
30 shm->a5[childno] = rand32();
31 goto retry_maxnode;
36 struct syscallentry syscall_mbind = {
37 .name = "mbind",
38 .num_args = 6,
39 .arg1name = "start",
40 .arg1type = ARG_MMAP,
42 .arg2name = "len",
44 .arg3name = "mode",
45 .arg3type = ARG_LIST,
46 .arg3list = {
47 .num = 4,
48 .values = { MPOL_DEFAULT, MPOL_BIND, MPOL_INTERLEAVE, MPOL_PREFERRED },
51 .arg4name = "nmask",
52 .arg4type = ARG_ADDRESS,
54 .arg5name = "maxnode",
55 .arg5type = ARG_RANGE,
56 .low5range = 0,
57 .hi5range = 32,
59 .arg6name = "flags",
60 .arg6type = ARG_LIST,
61 .arg6list = {
62 .num = 2,
63 .values = { MPOL_F_STATIC_NODES, MPOL_F_RELATIVE_NODES },
65 .sanitise = sanitise_mbind,
66 .group = GROUP_VM,