paul@8 | 1 | #include "file_pager.h" |
paul@8 | 2 | |
paul@8 | 3 | /* Initialise a pager for a file with a unique file identifier and shared page |
paul@8 | 4 | mapper for moderating access to loaded pages. */ |
paul@8 | 5 | |
paul@8 | 6 | FilePager::FilePager(fileid_t fileid, PageMapper *mapper) |
paul@8 | 7 | : Pager(mapper), fileid(fileid) |
paul@8 | 8 | { |
paul@8 | 9 | } |
paul@8 | 10 | |
paul@8 | 11 | long FilePager::mmap(size_t position, size_t length, size_t *start_pos, size_t *end_pos, size_t *data_end) |
paul@8 | 12 | { |
paul@8 | 13 | /* Set the limits of the paged region. */ |
paul@8 | 14 | |
paul@8 | 15 | Pager::mmap(position, length, start_pos, end_pos, data_end); |
paul@8 | 16 | |
paul@8 | 17 | /* Obtain the amount of the region that is populated with file data. */ |
paul@8 | 18 | |
paul@8 | 19 | *data_end = get_data_size() - _start; |
paul@8 | 20 | |
paul@8 | 21 | if (*data_end > _size) |
paul@8 | 22 | *data_end = _size; |
paul@8 | 23 | |
paul@8 | 24 | return L4_EOK; |
paul@8 | 25 | } |
paul@8 | 26 | |
paul@8 | 27 | // vim: tabstop=4 expandtab shiftwidth=4 |