-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfile.c
58 lines (47 loc) · 1.41 KB
/
file.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* file.c: Implementation of memory backed file object (mmaped object). */
#include "vm/vm.h"
static bool file_backed_swap_in (struct page *page, void *kva);
static bool file_backed_swap_out (struct page *page);
static void file_backed_destroy (struct page *page);
/* DO NOT MODIFY this struct */
static const struct page_operations file_ops = {
.swap_in = file_backed_swap_in,
.swap_out = file_backed_swap_out,
.destroy = file_backed_destroy,
.type = VM_FILE,
};
/* The initializer of file vm */
void
vm_file_init (void) {
}
/* Initialize the file backed page */
bool
file_backed_initializer (struct page *page, enum vm_type type, void *kva) {
/* Set up the handler */
page->operations = &file_ops;
struct file_page *file_page = &page->file;
}
/* Swap in the page by read contents from the file. */
static bool
file_backed_swap_in (struct page *page, void *kva) {
struct file_page *file_page UNUSED = &page->file;
}
/* Swap out the page by writeback contents to the file. */
static bool
file_backed_swap_out (struct page *page) {
struct file_page *file_page UNUSED = &page->file;
}
/* Destory the file backed page. PAGE will be freed by the caller. */
static void
file_backed_destroy (struct page *page) {
struct file_page *file_page UNUSED = &page->file;
}
/* Do the mmap */
void *
do_mmap (void *addr, size_t length, int writable,
struct file *file, off_t offset) {
}
/* Do the munmap */
void
do_munmap (void *addr) {
}