1.1 --- a/libfsclient/lib/src/file.cc Sat May 11 00:49:24 2024 +0200
1.2 +++ b/libfsclient/lib/src/file.cc Sat May 11 01:47:53 2024 +0200
1.3 @@ -62,6 +62,11 @@
1.4
1.5 else
1.6 file->data_end = 0;
1.7 +
1.8 + /* Reset the current position if a region is empty. */
1.9 +
1.10 + if (!file->data_end)
1.11 + file->data_current = 0;
1.12 }
1.13
1.14
1.15 @@ -361,6 +366,24 @@
1.16 return L4_EOK;
1.17 }
1.18
1.19 +/* Refresh position and size data from the file or pipe. */
1.20 +
1.21 +long file_refresh(file_t *file)
1.22 +{
1.23 + if (l4_is_invalid_cap(file->ref))
1.24 + return -L4_EINVAL;
1.25 +
1.26 + client_Flush _file(file->ref);
1.27 + long err = _file.refresh(&file->data_current, &file->size, &file->end_pos);
1.28 +
1.29 + if (err)
1.30 + return err;
1.31 +
1.32 + _update_extent(file);
1.33 +
1.34 + return L4_EOK;
1.35 +}
1.36 +
1.37 /* Map a region of the given file to a memory region, obtaining an updated file
1.38 size and populated data details. Unmap any previously mapped region. */
1.39
1.40 @@ -695,11 +718,6 @@
1.41 if (sync)
1.42 pipe->data_current = data_current;
1.43
1.44 - /* Handle any case where the current region has been exhausted. */
1.45 -
1.46 - if (!file_populated_span(pipe))
1.47 - pipe->data_current = 0;
1.48 -
1.49 /* Attach memory if necessary. */
1.50
1.51 if (pipe->memory == NULL)