1.1 --- a/libfsclient/include/fsclient/file.h Tue Jun 07 01:14:05 2022 +0200
1.2 +++ b/libfsclient/include/fsclient/file.h Tue Jun 07 18:00:28 2022 +0200
1.3 @@ -112,6 +112,8 @@
1.4 long file_mmap(file_t *file, offset_t position, offset_t length,
1.5 offset_t start_visible, offset_t end_visible,
1.6 l4re_rm_flags_t region_flags);
1.7 +long file_mmap_only(file_t *file, offset_t position, offset_t length,
1.8 + offset_t start_visible, offset_t end_visible);
1.9 flags_t file_opening_flags(l4re_rm_flags_t rm_flags);
1.10 l4re_rm_flags_t file_region_flags(flags_t flags);
1.11 long file_resize(file_t *file, offset_t size);
2.1 --- a/libfsclient/lib/src/file.cc Tue Jun 07 01:14:05 2022 +0200
2.2 +++ b/libfsclient/lib/src/file.cc Tue Jun 07 18:00:28 2022 +0200
2.3 @@ -356,15 +356,11 @@
2.4 l4re_rm_flags_t region_flags)
2.5 {
2.6 char *memory = file->memory;
2.7 - client_MappedFile mapped_file(file->ref);
2.8 - long err = mapped_file.mmap(position, length, start_visible, end_visible,
2.9 - &file->start_pos, &file->end_pos, &file->size);
2.10 + long err = file_mmap_only(file, position, length, start_visible, end_visible);
2.11
2.12 if (err)
2.13 return err;
2.14
2.15 - _update_extent(file);
2.16 -
2.17 err = ipc_attach_dataspace_align(file->ref, file_span(file),
2.18 L4RE_RM_F_SEARCH_ADDR | region_flags,
2.19 L4_PAGESHIFT,
2.20 @@ -378,6 +374,24 @@
2.21 return L4_EOK;
2.22 }
2.23
2.24 +/* Request access to a region of the given file, obtaining an updated file size
2.25 + and populated data details. The region is not mapped, however. */
2.26 +
2.27 +long file_mmap_only(file_t *file, offset_t position, offset_t length,
2.28 + offset_t start_visible, offset_t end_visible)
2.29 +{
2.30 + client_MappedFile mapped_file(file->ref);
2.31 + long err = mapped_file.mmap(position, length, start_visible, end_visible,
2.32 + &file->start_pos, &file->end_pos, &file->size);
2.33 +
2.34 + if (err)
2.35 + return err;
2.36 +
2.37 + _update_extent(file);
2.38 +
2.39 + return L4_EOK;
2.40 +}
2.41 +
2.42 /* Return opening flags compatible with the given region flags. */
2.43
2.44 flags_t file_opening_flags(l4re_rm_flags_t rm_flags)
3.1 --- a/tests/Makefile Tue Jun 07 01:14:05 2022 +0200
3.2 +++ b/tests/Makefile Tue Jun 07 18:00:28 2022 +0200
3.3 @@ -30,7 +30,7 @@
3.4
3.5 # Individual interfaces.
3.6
3.7 -CLIENT_INTERFACES_CC = dataspace mapped_file
3.8 +CLIENT_INTERFACES_CC = dataspace
3.9
3.10 # Generated and plain source files.
3.11
4.1 --- a/tests/dstest_file_mapping.cc Tue Jun 07 01:14:05 2022 +0200
4.2 +++ b/tests/dstest_file_mapping.cc Tue Jun 07 18:00:28 2022 +0200
4.3 @@ -32,29 +32,6 @@
4.4 #include <mem/memory_utils.h>
4.5
4.6 #include "dataspace_client.h"
4.7 -#include "mapped_file_client.h"
4.8 -
4.9 -
4.10 -
4.11 -/* NOTE: Copied from libfsclient. */
4.12 -
4.13 -static void _update_extent(file_t *file)
4.14 -{
4.15 - /* Handle files ending after or within the region. */
4.16 -
4.17 - if (file->size > file->start_pos)
4.18 - {
4.19 - if (file->size > file->end_pos)
4.20 - file->data_end = file->end_pos - file->start_pos;
4.21 - else
4.22 - file->data_end = file->size - file->start_pos;
4.23 - }
4.24 -
4.25 - /* Handle files ending before the region. */
4.26 -
4.27 - else
4.28 - file->data_end = 0;
4.29 -}
4.30
4.31
4.32
4.33 @@ -91,11 +68,9 @@
4.34 return 1;
4.35 }
4.36
4.37 - /* A region of the file is mapped. */
4.38 + /* A region of the file is mapped but not attached. */
4.39
4.40 - client_MappedFile mapped_file(file.ref);
4.41 -
4.42 - err = mapped_file.mmap(0, page(10), 0, 0, &file.start_pos, &file.end_pos, &file.size);
4.43 + err = file_mmap_only(&file, 0, page(10), 0, 0);
4.44
4.45 if (err)
4.46 {
4.47 @@ -106,7 +81,6 @@
4.48 /* Fix up the file data structure manually. */
4.49
4.50 file.memory = (char *) 0x2000000;
4.51 - _update_extent(&file);
4.52
4.53 /* Explicitly map the file into this address space, without region mapper
4.54 usage. The receive window base must be a multiple of its size. */