CS318 - Pintos
Pintos source browser for JHU CS318 course
src
tests
vm
mmap-over-stk.c
Go to the documentation of this file.
1
/** Verifies that mapping over the stack segment is disallowed. */
2
3
#include <
stdint.h
>
4
#include <
round.h
>
5
#include <syscall.h>
6
#include "
tests/lib.h
"
7
#include "
tests/main.h
"
8
9
void
10
test_main
(
void
)
11
{
12
int
handle;
13
uintptr_t
handle_page =
ROUND_DOWN
((
uintptr_t
) &handle, 4096);
14
15
CHECK
((handle =
open
(
"sample.txt"
)) > 1,
"open \"sample.txt\""
);
16
CHECK
(
mmap
(handle, (
void
*) handle_page) ==
MAP_FAILED
,
17
"try to mmap over stack segment"
);
18
}
19
lib.h
CHECK
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition:
lib.h:29
MAP_FAILED
#define MAP_FAILED
Definition:
syscall.h:13
test_main
void test_main(void)
Verifies that mapping over the stack segment is disallowed.
Definition:
mmap-over-stk.c:10
open
int open(const char *file)
Definition:
syscall.c:103
round.h
stdint.h
main.h
ROUND_DOWN
#define ROUND_DOWN(X, STEP)
Yields X rounded down to the nearest multiple of STEP.
Definition:
round.h:14
mmap
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition:
syscall.c:145
uintptr_t
uint32_t uintptr_t
Definition:
stdint.h:36
Generated on Thu Aug 22 2019 10:19:15 for CS318 - Pintos by
1.8.16