1.1 --- a/libfsclient/lib/src/client.cc Fri May 10 14:46:04 2024 +0200
1.2 +++ b/libfsclient/lib/src/client.cc Fri May 10 14:49:52 2024 +0200
1.3 @@ -140,12 +140,7 @@
1.4
1.5 else if (position == file->end_pos)
1.6 {
1.7 - err = client_next_region(file);
1.8 - if (err)
1.9 - return err;
1.10 -
1.11 - file->data_current = 0;
1.12 - return L4_EOK;
1.13 + return client_next_region(file);
1.14 }
1.15
1.16 /* Within the current pipe region, synchronise with the pipe object. */
1.17 @@ -283,10 +278,10 @@
1.18 stream->flags = flags;
1.19 stream->ref = ref;
1.20
1.21 - /* Test for pipe-based access, switching to memory mapped access if not
1.22 - supported. */
1.23 + /* Synchronise the state of the stream, testing for pipe-based access and
1.24 + switching to memory mapped access if not supported. */
1.25
1.26 - long err = client_current_region(stream);
1.27 + long err = client_sync_stream(stream);
1.28
1.29 if (err == -L4_EBADPROTO)
1.30 stream->object_flags |= OBJECT_SUPPORTS_MMAP;
1.31 @@ -310,6 +305,19 @@
1.32 return stream;
1.33 }
1.34
1.35 +/* Initialise the stream data position to the end of any existing data. */
1.36 +
1.37 +long client_sync_stream(file_t *file)
1.38 +{
1.39 + long err = client_current_region(file);
1.40 +
1.41 + if (err)
1.42 + return err;
1.43 +
1.44 + file->data_current = file->data_end;
1.45 + return err;
1.46 +}
1.47 +
1.48
1.49
1.50 /* Open a filesystem object. */
1.51 @@ -608,7 +616,13 @@
1.52 if (!client_opened(file))
1.53 return -L4_EINVAL;
1.54
1.55 - return pipe_next(file);
1.56 + long err = pipe_next(file);
1.57 +
1.58 + if (err)
1.59 + return err;
1.60 +
1.61 + file->data_current = 0;
1.62 + return L4_EOK;
1.63 }
1.64
1.65