1.1 --- a/libfsclient/lib/src/client.cc Fri May 10 14:49:52 2024 +0200
1.2 +++ b/libfsclient/lib/src/client.cc Fri May 10 19:00:38 2024 +0200
1.3 @@ -209,7 +209,7 @@
1.4 if (file->object_flags & OBJECT_SUPPORTS_MMAP)
1.5 return client_mmap(file, client_tell(file), count, 0, 0,
1.6 file_region_flags(file->flags));
1.7 - else if (pipe_current(file))
1.8 + else if (pipe_current(file, 0))
1.9 return NULL;
1.10 }
1.11
1.12 @@ -305,17 +305,16 @@
1.13 return stream;
1.14 }
1.15
1.16 -/* Initialise the stream data position to the end of any existing data. */
1.17 +/* Initialise the stream data position to the end of any existing data for an
1.18 + output stream. For an input stream, initialise the position to the end of
1.19 + consumed data, preserving any unconsumed data. */
1.20
1.21 long client_sync_stream(file_t *file)
1.22 {
1.23 - long err = client_current_region(file);
1.24 + if (!client_opened(file))
1.25 + return -L4_EINVAL;
1.26
1.27 - if (err)
1.28 - return err;
1.29 -
1.30 - file->data_current = file->data_end;
1.31 - return err;
1.32 + return pipe_current(file, 1);
1.33 }
1.34
1.35
1.36 @@ -558,24 +557,15 @@
1.37
1.38
1.39
1.40 -/* Obtain the current region of a pipe. */
1.41 +/* Obtain the current region of a pipe, updating the extent of populated data
1.42 + and only changing the current position if no populated data exists. */
1.43
1.44 long client_current_region(file_t *file)
1.45 {
1.46 if (!client_opened(file))
1.47 return -L4_EINVAL;
1.48
1.49 - long err = pipe_current(file);
1.50 -
1.51 - if (err)
1.52 - return err;
1.53 -
1.54 - /* Handle any case where the current region has been exhausted. */
1.55 -
1.56 - if (!file_populated_span(file))
1.57 - file->data_current = 0;
1.58 -
1.59 - return L4_EOK;
1.60 + return pipe_current(file, 0);
1.61 }
1.62
1.63
1.64 @@ -616,13 +606,7 @@
1.65 if (!client_opened(file))
1.66 return -L4_EINVAL;
1.67
1.68 - long err = pipe_next(file);
1.69 -
1.70 - if (err)
1.71 - return err;
1.72 -
1.73 - file->data_current = 0;
1.74 - return L4_EOK;
1.75 + return pipe_next(file);
1.76 }
1.77
1.78