PKUOS - Pintos
Pintos source browser for PKU Operating System course
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
9void
10test_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
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition: syscall.c:145
int open(const char *file)
Definition: syscall.c:103
#define MAP_FAILED
Definition: syscall.h:13
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition: lib.h:29
void test_main(void)
Verifies that mapping over the stack segment is disallowed.
Definition: mmap-over-stk.c:10
#define ROUND_DOWN(X, STEP)
Yields X rounded down to the nearest multiple of STEP.
Definition: round.h:14
uint32_t uintptr_t
Definition: stdint.h:36