1.1 --- a/client/file.cc Sun Apr 11 19:34:07 2021 +0200
1.2 +++ b/client/file.cc Mon Apr 12 00:12:51 2021 +0200
1.3 @@ -124,7 +124,8 @@
1.4 return -L4_EINVAL;
1.5
1.6 client_Opener opener(server);
1.7 - unsigned long size, flags;
1.8 + length_t size;
1.9 + flags_t flags;
1.10 long err;
1.11
1.12 file_init(file);
1.13 @@ -175,7 +176,7 @@
1.14 /* Map a region of the given file to a memory region, obtaining an updated file
1.15 size and populated data details. Unmap any previously mapped region. */
1.16
1.17 -long file_mmap(file_t *file, offset_t position, offset_t length)
1.18 +long file_mmap(file_t *file, offset_t position, length_t length)
1.19 {
1.20 char *memory = file->memory;
1.21 client_MappedFile mapped_file(file->ref);
1.22 @@ -217,15 +218,15 @@
1.23
1.24 /* Return the amount of data in the mapped region for the given file. */
1.25
1.26 -offset_t file_populated_span(file_t *file)
1.27 +length_t file_populated_span(file_t *file)
1.28 {
1.29 - offset_t size = file_span(file);
1.30 + length_t size = file_span(file);
1.31 return (file->data_end < size) ? file->data_end : size;
1.32 }
1.33
1.34 /* Return the size of the mapped region for the given file. */
1.35
1.36 -offset_t file_span(file_t *file)
1.37 +length_t file_span(file_t *file)
1.38 {
1.39 return file->end_pos - file->start_pos;
1.40 }
1.41 @@ -235,9 +236,9 @@
1.42 /* Get a pointer to any terminated string at the given offset or NULL if the
1.43 data from offset is not terminated. */
1.44
1.45 -char *file_string_get(file_t *file, offset_t offset)
1.46 +char *file_string_get(file_t *file, length_t offset)
1.47 {
1.48 - offset_t limit = file_span(file) - offset;
1.49 + length_t limit = file_span(file) - offset;
1.50
1.51 if (strnlen(file->memory + offset, limit) < limit)
1.52 return file->memory + offset;
1.53 @@ -250,10 +251,10 @@
1.54 characters copied, excluding the zero terminator is provided via the written
1.55 parameter if it is not specified as NULL. */
1.56
1.57 -int file_string_set(file_t *file, const char *data, offset_t offset,
1.58 - offset_t *written)
1.59 +int file_string_set(file_t *file, const char *data, length_t offset,
1.60 + length_t *written)
1.61 {
1.62 - offset_t i, pos, limit = file_span(file);
1.63 + length_t i, pos, limit = file_span(file);
1.64
1.65 /* Do not attempt to copy data with an invalid offset. */
1.66
1.67 @@ -292,7 +293,7 @@
1.68
1.69 /* Return the number of remaining populated bytes in the region. */
1.70
1.71 -offset_t file_data_available(file_t *file)
1.72 +length_t file_data_available(file_t *file)
1.73 {
1.74 return file_populated_span(file) - file->data_current;
1.75 }
1.76 @@ -304,6 +305,15 @@
1.77 return file->memory + file->data_current;
1.78 }
1.79
1.80 +/* Return the amount of remaining space in the region. */
1.81 +
1.82 +length_t file_data_space(file_t *file)
1.83 +{
1.84 + return file_span(file) - file->data_current;
1.85 +}
1.86 +
1.87 +
1.88 +
1.89 /* Return the current access position in the file. */
1.90
1.91 offset_t file_data_current_position(file_t *file)
1.92 @@ -318,13 +328,6 @@
1.93 return file->start_pos + file->data_end;
1.94 }
1.95
1.96 -/* Return the amount of remaining space in the region. */
1.97 -
1.98 -offset_t file_data_space(file_t *file)
1.99 -{
1.100 - return file_span(file) - file->data_current;
1.101 -}
1.102 -
1.103
1.104
1.105 /* Copy data to the given buffer from the current data position, updating the
1.106 @@ -358,7 +361,7 @@
1.107
1.108 /* Open two pipe endpoints using the given pipe server. */
1.109
1.110 -long pipe_open(offset_t size, file_t *reader, file_t *writer, l4_cap_idx_t server)
1.111 +long pipe_open(length_t size, file_t *reader, file_t *writer, l4_cap_idx_t server)
1.112 {
1.113 if (l4_is_invalid_cap(server))
1.114 return -L4_EINVAL;
1.115 @@ -437,7 +440,7 @@
1.116
1.117 /* Set the size of the written region. */
1.118
1.119 -long pipe_written(file_t *pipe, offset_t size)
1.120 +long pipe_written(file_t *pipe, length_t size)
1.121 {
1.122 if (size <= pipe->size)
1.123 {