1.1 --- a/libfsclient/include/fsclient/client.h Fri May 10 14:46:04 2024 +0200
1.2 +++ b/libfsclient/include/fsclient/client.h Fri May 10 14:49:52 2024 +0200
1.3 @@ -36,6 +36,7 @@
1.4 /* Stream access operations. */
1.5
1.6 file_t *client_get_stream(const char *name, flags_t flags);
1.7 +long client_sync_stream(file_t *file);
1.8
1.9 /* Opening and closing operations. */
1.10
2.1 --- a/libfsclient/lib/src/client.cc Fri May 10 14:46:04 2024 +0200
2.2 +++ b/libfsclient/lib/src/client.cc Fri May 10 14:49:52 2024 +0200
2.3 @@ -140,12 +140,7 @@
2.4
2.5 else if (position == file->end_pos)
2.6 {
2.7 - err = client_next_region(file);
2.8 - if (err)
2.9 - return err;
2.10 -
2.11 - file->data_current = 0;
2.12 - return L4_EOK;
2.13 + return client_next_region(file);
2.14 }
2.15
2.16 /* Within the current pipe region, synchronise with the pipe object. */
2.17 @@ -283,10 +278,10 @@
2.18 stream->flags = flags;
2.19 stream->ref = ref;
2.20
2.21 - /* Test for pipe-based access, switching to memory mapped access if not
2.22 - supported. */
2.23 + /* Synchronise the state of the stream, testing for pipe-based access and
2.24 + switching to memory mapped access if not supported. */
2.25
2.26 - long err = client_current_region(stream);
2.27 + long err = client_sync_stream(stream);
2.28
2.29 if (err == -L4_EBADPROTO)
2.30 stream->object_flags |= OBJECT_SUPPORTS_MMAP;
2.31 @@ -310,6 +305,19 @@
2.32 return stream;
2.33 }
2.34
2.35 +/* Initialise the stream data position to the end of any existing data. */
2.36 +
2.37 +long client_sync_stream(file_t *file)
2.38 +{
2.39 + long err = client_current_region(file);
2.40 +
2.41 + if (err)
2.42 + return err;
2.43 +
2.44 + file->data_current = file->data_end;
2.45 + return err;
2.46 +}
2.47 +
2.48
2.49
2.50 /* Open a filesystem object. */
2.51 @@ -608,7 +616,13 @@
2.52 if (!client_opened(file))
2.53 return -L4_EINVAL;
2.54
2.55 - return pipe_next(file);
2.56 + long err = pipe_next(file);
2.57 +
2.58 + if (err)
2.59 + return err;
2.60 +
2.61 + file->data_current = 0;
2.62 + return L4_EOK;
2.63 }
2.64
2.65