Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / kernel / linux_syscalls / mmap.c
1 #include <lwk/kernel.h>
2 #include <lwk/task.h>
3 #include <lwk/aspace.h>
4 #include <arch/mman.h>
5
6 long
7 sys_mmap(
8         unsigned long addr,
9         unsigned long len,
10         unsigned long prot,
11         unsigned long flags,
12         unsigned long fd,
13         unsigned long off
14 )
15 {
16         unsigned long mmap_brk;
17
18         /* For now we only support private/anonymous mappings */
19         if (!(flags & MAP_PRIVATE) || !(flags & MAP_ANONYMOUS))
20                 return -EINVAL;
21
22         if (len != round_up(len, PAGE_SIZE))
23                 return -EINVAL;
24
25         mmap_brk = current->aspace->mmap_brk;
26         mmap_brk = round_down(mmap_brk - len, PAGE_SIZE);
27
28         /* Protect against extending into the UNIX data segment */
29         if (mmap_brk <= current->aspace->brk)
30                 return -ENOMEM;
31
32         current->aspace->mmap_brk = mmap_brk;
33         return mmap_brk;
34 }
35