# HG changeset patch # User Paul Boddie # Date 1615654163 -3600 # Node ID 14888a561fb945c98ac84f035815e1d525e48e93 # Parent 17dae091eb33e0e84cb24d93283eb69711c84022 Introduced distinct span and populated span functions for mapped regions. diff -r 17dae091eb33 -r 14888a561fb9 dstest_host_client.cc --- a/dstest_host_client.cc Sat Mar 13 01:36:26 2021 +0100 +++ b/dstest_host_client.cc Sat Mar 13 17:49:23 2021 +0100 @@ -90,9 +90,9 @@ return 1; } - for (unsigned long offset = 0; offset < file_span(&file); offset += step) + for (unsigned long offset = 0; offset < file_populated_span(&file); offset += step) { - unsigned long remaining = file_span(&file) - offset; + unsigned long remaining = file_populated_span(&file) - offset; unsigned long sample_remaining = remaining < sample ? remaining : sample; printf("%ld bytes from %p...\n", sample_remaining, (file.memory + offset)); diff -r 17dae091eb33 -r 14888a561fb9 dstest_test_client.cc --- a/dstest_test_client.cc Sat Mar 13 01:36:26 2021 +0100 +++ b/dstest_test_client.cc Sat Mar 13 17:49:23 2021 +0100 @@ -88,9 +88,9 @@ for (unsigned int read_counter = 0; read_counter < REGION_ITERATIONS; read_counter++) { - for (unsigned long offset = 0; offset < file_span(&file); offset += step) + for (unsigned long offset = 0; offset < file_populated_span(&file); offset += step) { - unsigned long remaining = file_span(&file) - offset; + unsigned long remaining = file_populated_span(&file) - offset; unsigned long sample_remaining = remaining < sample ? remaining : sample; strncpy(buf, (file.memory + offset), sample_remaining); diff -r 17dae091eb33 -r 14888a561fb9 file.cc --- a/file.cc Sat Mar 13 01:36:26 2021 +0100 +++ b/file.cc Sat Mar 13 17:49:23 2021 +0100 @@ -100,11 +100,17 @@ /* Return the amount of data in the mapped region for the given file. */ -offset_t file_span(file_t *file) +offset_t file_populated_span(file_t *file) { - offset_t size = file->end_pos - file->start_pos; - + offset_t size = file_span(file); return (file->data_end < size) ? file->data_end : size; } +/* Return the size of the mapped region for the given file. */ + +offset_t file_span(file_t *file) +{ + return file->end_pos - file->start_pos; +} + // vim: tabstop=2 expandtab shiftwidth=2 diff -r 17dae091eb33 -r 14888a561fb9 file.h --- a/file.h Sat Mar 13 01:36:26 2021 +0100 +++ b/file.h Sat Mar 13 17:49:23 2021 +0100 @@ -52,13 +52,17 @@ -/* File access operations. */ +/* File lifecycle operations. */ void file_close(file_t *file); long file_context(file_t *file, l4_cap_idx_t server); void file_init(file_t *file); +long file_open(file_t *file, file_t *context); + +/* File access region operations. */ + long file_mmap(file_t *file, offset_t position, offset_t length); -long file_open(file_t *file, file_t *context); +offset_t file_populated_span(file_t *file); offset_t file_span(file_t *file); EXTERN_C_END