1.1 --- a/dstest_host_client.cc Sat Mar 13 01:36:26 2021 +0100
1.2 +++ b/dstest_host_client.cc Sat Mar 13 17:49:23 2021 +0100
1.3 @@ -90,9 +90,9 @@
1.4 return 1;
1.5 }
1.6
1.7 - for (unsigned long offset = 0; offset < file_span(&file); offset += step)
1.8 + for (unsigned long offset = 0; offset < file_populated_span(&file); offset += step)
1.9 {
1.10 - unsigned long remaining = file_span(&file) - offset;
1.11 + unsigned long remaining = file_populated_span(&file) - offset;
1.12 unsigned long sample_remaining = remaining < sample ? remaining : sample;
1.13
1.14 printf("%ld bytes from %p...\n", sample_remaining, (file.memory + offset));
2.1 --- a/dstest_test_client.cc Sat Mar 13 01:36:26 2021 +0100
2.2 +++ b/dstest_test_client.cc Sat Mar 13 17:49:23 2021 +0100
2.3 @@ -88,9 +88,9 @@
2.4
2.5 for (unsigned int read_counter = 0; read_counter < REGION_ITERATIONS; read_counter++)
2.6 {
2.7 - for (unsigned long offset = 0; offset < file_span(&file); offset += step)
2.8 + for (unsigned long offset = 0; offset < file_populated_span(&file); offset += step)
2.9 {
2.10 - unsigned long remaining = file_span(&file) - offset;
2.11 + unsigned long remaining = file_populated_span(&file) - offset;
2.12 unsigned long sample_remaining = remaining < sample ? remaining : sample;
2.13
2.14 strncpy(buf, (file.memory + offset), sample_remaining);
3.1 --- a/file.cc Sat Mar 13 01:36:26 2021 +0100
3.2 +++ b/file.cc Sat Mar 13 17:49:23 2021 +0100
3.3 @@ -100,11 +100,17 @@
3.4
3.5 /* Return the amount of data in the mapped region for the given file. */
3.6
3.7 -offset_t file_span(file_t *file)
3.8 +offset_t file_populated_span(file_t *file)
3.9 {
3.10 - offset_t size = file->end_pos - file->start_pos;
3.11 -
3.12 + offset_t size = file_span(file);
3.13 return (file->data_end < size) ? file->data_end : size;
3.14 }
3.15
3.16 +/* Return the size of the mapped region for the given file. */
3.17 +
3.18 +offset_t file_span(file_t *file)
3.19 +{
3.20 + return file->end_pos - file->start_pos;
3.21 +}
3.22 +
3.23 // vim: tabstop=2 expandtab shiftwidth=2
4.1 --- a/file.h Sat Mar 13 01:36:26 2021 +0100
4.2 +++ b/file.h Sat Mar 13 17:49:23 2021 +0100
4.3 @@ -52,13 +52,17 @@
4.4
4.5
4.6
4.7 -/* File access operations. */
4.8 +/* File lifecycle operations. */
4.9
4.10 void file_close(file_t *file);
4.11 long file_context(file_t *file, l4_cap_idx_t server);
4.12 void file_init(file_t *file);
4.13 +long file_open(file_t *file, file_t *context);
4.14 +
4.15 +/* File access region operations. */
4.16 +
4.17 long file_mmap(file_t *file, offset_t position, offset_t length);
4.18 -long file_open(file_t *file, file_t *context);
4.19 +offset_t file_populated_span(file_t *file);
4.20 offset_t file_span(file_t *file);
4.21
4.22 EXTERN_C_END