# HG changeset patch # User Paul Boddie # Date 1615154704 -3600 # Node ID 63b595c566fea1fddda9bfddcce898d35adace4e # Parent 8965e00ba1975423146db68ddd6bfd9949fd17e7 Simplified the file API slightly. diff -r 8965e00ba197 -r 63b595c566fe dstest_host_client.cc --- a/dstest_host_client.cc Thu Mar 04 23:50:40 2021 +0100 +++ b/dstest_host_client.cc Sun Mar 07 23:05:04 2021 +0100 @@ -72,7 +72,7 @@ file_t file; - err = file_open(&file, context.ref); + err = file_open(&file, &context); if (err) { diff -r 8965e00ba197 -r 63b595c566fe dstest_test_client.cc --- a/dstest_test_client.cc Thu Mar 04 23:50:40 2021 +0100 +++ b/dstest_test_client.cc Sun Mar 07 23:05:04 2021 +0100 @@ -50,7 +50,7 @@ /* An activity opening and reading from a file. */ -static long activity(l4_cap_idx_t context_ref, unsigned long fileid, unsigned int start_page) +static long activity(file_t *context, unsigned long fileid, unsigned int start_page) { unsigned long step = page(1); unsigned long sample = page(1); @@ -63,7 +63,7 @@ file_t file; - long err = file_open(&file, context_ref); + long err = file_open(&file, context); if (err) { @@ -118,7 +118,7 @@ -static long activity_iterate(file_t *file, unsigned long fileid, unsigned int start_page) +static long activity_iterate(file_t *context, unsigned long fileid, unsigned int start_page) { long err; @@ -126,7 +126,7 @@ for (unsigned int iteration = 0; iteration < ACTIVITY_ITERATIONS; iteration++) { - err = activity(file->ref, fileid, start_page); + err = activity(context, fileid, start_page); if (err) break; } diff -r 8965e00ba197 -r 63b595c566fe file.cc --- a/file.cc Thu Mar 04 23:50:40 2021 +0100 +++ b/file.cc Sun Mar 07 23:05:04 2021 +0100 @@ -89,13 +89,13 @@ return ipc_attach_dataspace(file->ref, file->end_pos - file->start_pos, (void **) &file->memory); } -/* Open a file using the given structure and context reference. */ +/* Open a file using the given structure and context. */ -long file_open(file_t *file, l4_cap_idx_t context_ref) +long file_open(file_t *file, file_t *context) { - client_OpenerContext context(context_ref); + client_OpenerContext openercontext(context->ref); file_init(file); - return context.open(L4_FPAGE_RW, &file->size, &file->ref); + return openercontext.open(L4_FPAGE_RW, &file->size, &file->ref); } /* Return the amount of data in the mapped region for the given file. */ diff -r 8965e00ba197 -r 63b595c566fe file.h --- a/file.h Thu Mar 04 23:50:40 2021 +0100 +++ b/file.h Sun Mar 07 23:05:04 2021 +0100 @@ -41,19 +41,24 @@ /* File region parameters. */ - offset_t start_pos, end_pos; /* start and end of region */ + offset_t start_pos, end_pos; /* start and end positions of region */ offset_t data_end; /* amount of data in the region */ - offset_t size; /* total size of file */ + + /* Total size of file. */ + + offset_t size; } file_t; + + /* File access 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_mmap(file_t *file, offset_t position, offset_t length); -long file_open(file_t *file, l4_cap_idx_t context_ref); +long file_open(file_t *file, file_t *context); offset_t file_span(file_t *file); EXTERN_C_END