1.1 --- a/docs/wiki/Components Sat May 11 01:48:03 2024 +0200
1.2 +++ b/docs/wiki/Components Sat May 11 22:28:21 2024 +0200
1.3 @@ -403,13 +403,14 @@
1.4 operation from the `Flush` interface:
1.5
1.6 {{{
1.7 -refresh(out offset_t position, out offset_t size, out offset_t region_size)
1.8 +refresh(out offset_t position, out offset_t start_pos, out offset_t end_pos,
1.9 + out offset_t size, out object_flags_t object_flags)
1.10 }}}
1.11
1.12 -This provides details of the recorded access position in a region, the
1.13 -populated size (or amount of written data) in a region along with the size of
1.14 -the region. For a writing endpoint, the position and populated size will be
1.15 -the same.
1.16 +This provides details of the recorded access position in a region, the start
1.17 +and end positions defining the span of a region, along with the populated size
1.18 +(or amount of written data) in a region and the flags describing the object.
1.19 +For a writing endpoint, the position and populated size will be the same.
1.20
1.21 Navigation to the next available region of the pipe is performed using the
1.22 following operation from the `Pipe` interface:
2.1 --- a/fsaccess/input.c Sat May 11 01:48:03 2024 +0200
2.2 +++ b/fsaccess/input.c Sat May 11 22:28:21 2024 +0200
2.3 @@ -54,7 +54,7 @@
2.4 args[*num_args] = start;
2.5 (*num_args)++;
2.6
2.7 - /* NOTE: Only handling spaces as delimiters. */
2.8 + /* NOTE: Only handling regions of spaces as delimiters. */
2.9
2.10 start = strchr(start, ' ');
2.11
2.12 @@ -62,8 +62,13 @@
2.13 {
2.14 *start = '\0';
2.15
2.16 - if (start < end)
2.17 + while (start < end)
2.18 + {
2.19 start++;
2.20 +
2.21 + if (*start != ' ')
2.22 + break;
2.23 + }
2.24 }
2.25 }
2.26 }
3.1 --- a/libfsclient/include/fsclient/file.h Sat May 11 01:48:03 2024 +0200
3.2 +++ b/libfsclient/include/fsclient/file.h Sat May 11 22:28:21 2024 +0200
3.3 @@ -166,7 +166,7 @@
3.4
3.5 /* Pipe region operations. */
3.6
3.7 -long pipe_current(file_t *pipe, int sync);
3.8 +long pipe_current(file_t *pipe);
3.9 long pipe_next(file_t *pipe);
3.10 long pipe_written(file_t *pipe, offset_t size);
3.11
4.1 --- a/libfsclient/lib/src/client.cc Sat May 11 01:48:03 2024 +0200
4.2 +++ b/libfsclient/lib/src/client.cc Sat May 11 22:28:21 2024 +0200
4.3 @@ -209,7 +209,7 @@
4.4 if (file->object_flags & OBJECT_SUPPORTS_MMAP)
4.5 return client_mmap(file, client_tell(file), count, 0, 0,
4.6 file_region_flags(file->flags));
4.7 - else if (pipe_current(file, 0))
4.8 + else if (pipe_current(file))
4.9 return NULL;
4.10 }
4.11
4.12 @@ -278,8 +278,7 @@
4.13 stream->flags = flags;
4.14 stream->ref = ref;
4.15
4.16 - /* Synchronise the state of the stream, testing for pipe-based access and
4.17 - switching to memory mapped access if not supported. */
4.18 + /* Restore the state of the stream. */
4.19
4.20 client_sync_stream(stream);
4.21
4.22 @@ -311,12 +310,6 @@
4.23 if (!client_opened(file))
4.24 return -L4_EINVAL;
4.25
4.26 - long err = pipe_current(file, 1);
4.27 -
4.28 - if (err != -L4_EBADPROTO)
4.29 - return err;
4.30 -
4.31 - file->object_flags |= OBJECT_SUPPORTS_MMAP;
4.32 return file_refresh(file);
4.33 }
4.34
4.35 @@ -568,7 +561,7 @@
4.36 if (!client_opened(file))
4.37 return -L4_EINVAL;
4.38
4.39 - return pipe_current(file, 0);
4.40 + return pipe_current(file);
4.41 }
4.42
4.43
5.1 --- a/libfsclient/lib/src/file.cc Sat May 11 01:48:03 2024 +0200
5.2 +++ b/libfsclient/lib/src/file.cc Sat May 11 22:28:21 2024 +0200
5.3 @@ -374,14 +374,38 @@
5.4 return -L4_EINVAL;
5.5
5.6 client_Flush _file(file->ref);
5.7 - long err = _file.refresh(&file->data_current, &file->size, &file->end_pos);
5.8 + long err;
5.9 +
5.10 + /* Unmap any existing region since the endpoint may have been reconfigured. */
5.11 +
5.12 + if (file->memory != NULL)
5.13 + {
5.14 + err = ipc_detach_dataspace(file->memory);
5.15 + if (err)
5.16 + return err;
5.17 +
5.18 + file->memory = NULL;
5.19 + }
5.20 +
5.21 + /* Obtain the new details for the region. */
5.22 +
5.23 + err = _file.refresh(&file->data_current, &file->start_pos, &file->end_pos,
5.24 + &file->size, &file->object_flags);
5.25
5.26 if (err)
5.27 return err;
5.28
5.29 _update_extent(file);
5.30
5.31 - return L4_EOK;
5.32 + /* Attempt to map any replacement region. */
5.33 +
5.34 + if (!file_span(file))
5.35 + return L4_EOK;
5.36 +
5.37 + return ipc_attach_dataspace_align(file->ref, file_span(file),
5.38 + L4RE_RM_F_SEARCH_ADDR | file_region_flags(file->flags),
5.39 + L4_PAGESHIFT,
5.40 + (void **) &file->memory);
5.41 }
5.42
5.43 /* Map a region of the given file to a memory region, obtaining an updated file
5.44 @@ -407,14 +431,10 @@
5.45 if (err)
5.46 return err;
5.47
5.48 - err = ipc_attach_dataspace_align(file->ref, file_span(file),
5.49 - L4RE_RM_F_SEARCH_ADDR | region_flags,
5.50 - L4_PAGESHIFT,
5.51 - (void **) &file->memory);
5.52 - if (err)
5.53 - return err;
5.54 -
5.55 - return L4_EOK;
5.56 + return ipc_attach_dataspace_align(file->ref, file_span(file),
5.57 + L4RE_RM_F_SEARCH_ADDR | region_flags,
5.58 + L4_PAGESHIFT,
5.59 + (void **) &file->memory);
5.60 }
5.61
5.62 /* Request access to a region of the given file, obtaining an updated file size
5.63 @@ -702,22 +722,22 @@
5.64
5.65 /* Access the current region for a pipe endpoint. */
5.66
5.67 -long pipe_current(file_t *pipe, int sync)
5.68 +long pipe_current(file_t *pipe)
5.69 {
5.70 client_Flush _pipe(pipe->ref);
5.71 +
5.72 + /* The current position and flags are not updated by the refresh operation. */
5.73 +
5.74 offset_t data_current;
5.75 - long err = _pipe.refresh(&data_current, &pipe->size, &pipe->end_pos);
5.76 + object_flags_t object_flags;
5.77 + long err = _pipe.refresh(&data_current, &pipe->start_pos, &pipe->end_pos,
5.78 + &pipe->size, &object_flags);
5.79
5.80 if (err)
5.81 return err;
5.82
5.83 _update_extent(pipe);
5.84
5.85 - /* Obtain the current position if synchronising position state. */
5.86 -
5.87 - if (sync)
5.88 - pipe->data_current = data_current;
5.89 -
5.90 /* Attach memory if necessary. */
5.91
5.92 if (pipe->memory == NULL)
6.1 --- a/libfsserver/include/fsserver/file_pager.h Sat May 11 01:48:03 2024 +0200
6.2 +++ b/libfsserver/include/fsserver/file_pager.h Sat May 11 22:28:21 2024 +0200
6.3 @@ -34,6 +34,7 @@
6.4 protected:
6.5 FileProvider *_provider;
6.6 flags_t _flags;
6.7 + object_flags_t _object_flags;
6.8 offset_t _data_current;
6.9
6.10 /* Notification endpoint for event subscription. */
6.11 @@ -51,7 +52,8 @@
6.12 public:
6.13 fileid_t fileid;
6.14
6.15 - explicit FilePager(fileid_t fileid, FileProvider *provider, flags_t flags);
6.16 + explicit FilePager(fileid_t fileid, FileProvider *provider, flags_t flags,
6.17 + object_flags_t object_flags);
6.18
6.19 virtual void close();
6.20
6.21 @@ -66,8 +68,9 @@
6.22
6.23 virtual long flush(offset_t position, offset_t *size);
6.24
6.25 - virtual long refresh(offset_t *position, offset_t *populated_size,
6.26 - offset_t *region_size);
6.27 + virtual long refresh(offset_t *position, offset_t *start_pos,
6.28 + offset_t *end_pos, offset_t *size,
6.29 + object_flags_t *object_flags);
6.30
6.31 /* File methods. */
6.32
7.1 --- a/libfsserver/include/fsserver/pipe_pager.h Sat May 11 01:48:03 2024 +0200
7.2 +++ b/libfsserver/include/fsserver/pipe_pager.h Sat May 11 22:28:21 2024 +0200
7.3 @@ -60,7 +60,8 @@
7.4
7.5 /* Pager methods. */
7.6
7.7 - virtual long map(offset_t offset, map_address_t hot_spot, map_flags_t flags, l4_snd_fpage_t *region);
7.8 + virtual long map(offset_t offset, map_address_t hot_spot, map_flags_t flags,
7.9 + l4_snd_fpage_t *region);
7.10
7.11 /* Pipe methods. */
7.12
7.13 @@ -72,7 +73,9 @@
7.14
7.15 virtual long flush(offset_t position, offset_t *size);
7.16
7.17 - virtual long refresh(offset_t *position, offset_t *populated_size, offset_t *size);
7.18 + virtual long refresh(offset_t *position, offset_t *start_pos,
7.19 + offset_t *end_pos, offset_t *size,
7.20 + object_flags_t *object_flags);
7.21
7.22 /* Notification methods. */
7.23
8.1 --- a/libfsserver/lib/files/file_pager.cc Sat May 11 01:48:03 2024 +0200
8.2 +++ b/libfsserver/lib/files/file_pager.cc Sat May 11 22:28:21 2024 +0200
8.3 @@ -33,9 +33,11 @@
8.4 opening flags and a file registry. The provider offers a shared page mapper
8.5 for moderating access to loaded pages. */
8.6
8.7 -FilePager::FilePager(fileid_t fileid, FileProvider *provider, flags_t flags)
8.8 +FilePager::FilePager(fileid_t fileid, FileProvider *provider, flags_t flags,
8.9 + object_flags_t object_flags)
8.10 : Pager(provider->mapper(), file_region_flags(flags)),
8.11 - _provider(provider), _flags(flags), fileid(fileid)
8.12 + _provider(provider), _flags(flags), _object_flags(object_flags),
8.13 + fileid(fileid)
8.14 {
8.15 /* Initialise any recorded position in the mapped region for this
8.16 endpoint. */
8.17 @@ -83,12 +85,14 @@
8.18 return err;
8.19 }
8.20
8.21 -long FilePager::refresh(offset_t *position, offset_t *size,
8.22 - offset_t *region_size)
8.23 +long FilePager::refresh(offset_t *position, offset_t *start_pos, offset_t *end_pos,
8.24 + offset_t *size, object_flags_t *object_flags)
8.25 {
8.26 *position = _data_current;
8.27 + *start_pos = _start;
8.28 + *end_pos = _start + _size;
8.29 *size = _mapper->get_data_size();
8.30 - *region_size = _size;
8.31 + *object_flags = _object_flags;
8.32
8.33 return L4_EOK;
8.34 }
9.1 --- a/libfsserver/lib/files/file_provider.cc Sat May 11 01:48:03 2024 +0200
9.2 +++ b/libfsserver/lib/files/file_provider.cc Sat May 11 22:28:21 2024 +0200
9.3 @@ -1,7 +1,7 @@
9.4 /*
9.5 * An object providing access to file functionality.
9.6 *
9.7 - * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
9.8 + * Copyright (C) 2021, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
9.9 *
9.10 * This program is free software; you can redistribute it and/or
9.11 * modify it under the terms of the GNU General Public License as
9.12 @@ -63,16 +63,16 @@
9.13 object_flags_t *object_flags,
9.14 Resource **resource)
9.15 {
9.16 + *object_flags = OBJECT_SUPPORTS_MMAP | OBJECT_HAS_SIZE;
9.17 +
9.18 /* Initialise the pager with the provider and a reference to this object for
9.19 detaching from the provider. */
9.20
9.21 - FilePager *pager = new FilePager(_fileid, this, flags);
9.22 + FilePager *pager = new FilePager(_fileid, this, flags, *object_flags);
9.23
9.24 - /* Obtain the size details from the pager, also providing appropriate
9.25 - flags. */
9.26 + /* Obtain the size details from the pager. */
9.27
9.28 *size = pager->get_data_size();
9.29 - *object_flags = OBJECT_SUPPORTS_MMAP | OBJECT_HAS_SIZE;
9.30
9.31 this->attach();
9.32 *resource = pager;
10.1 --- a/libfsserver/lib/pipes/pipe_pager.cc Sat May 11 01:48:03 2024 +0200
10.2 +++ b/libfsserver/lib/pipes/pipe_pager.cc Sat May 11 22:28:21 2024 +0200
10.3 @@ -97,15 +97,24 @@
10.4
10.5 /* Return details of the current region. */
10.6
10.7 -long PipePager::refresh(offset_t *position, offset_t *populated_size, offset_t *size)
10.8 +long PipePager::refresh(offset_t *position, offset_t *start_pos,
10.9 + offset_t *end_pos, offset_t *size,
10.10 + object_flags_t *object_flags)
10.11 {
10.12 if (_mapper != NULL)
10.13 {
10.14 if (position != NULL)
10.15 *position = _data_current;
10.16
10.17 - *populated_size = _mapper->get_data_size();
10.18 - *size = _size;
10.19 + if (start_pos != NULL)
10.20 + *start_pos = 0;
10.21 +
10.22 + *end_pos = _size;
10.23 + *size = _mapper->get_data_size();
10.24 +
10.25 + if (object_flags != NULL)
10.26 + *object_flags = 0;
10.27 +
10.28 return L4_EOK;
10.29 }
10.30 else
10.31 @@ -134,7 +143,7 @@
10.32 _mapper = mapper;
10.33 _data_current = 0;
10.34
10.35 - return refresh(NULL, populated_size, size);
10.36 + return refresh(NULL, NULL, size, populated_size, NULL);
10.37 }
10.38
10.39 long PipePager::next_region_for_writer(offset_t *populated_size, offset_t *size)
10.40 @@ -154,7 +163,7 @@
10.41 _mapper = mapper;
10.42 _data_current = 0;
10.43
10.44 - return refresh(NULL, populated_size, size);
10.45 + return refresh(NULL, NULL, size, populated_size, NULL);
10.46 }
10.47
10.48 long PipePager::pipe_error()
11.1 --- a/libsystypes/idl/flush.idl Sat May 11 01:48:03 2024 +0200
11.2 +++ b/libsystypes/idl/flush.idl Sat May 11 22:28:21 2024 +0200
11.3 @@ -10,9 +10,12 @@
11.4
11.5 [opcode(5)] void flush(in offset_t position, out offset_t size);
11.6
11.7 - /* Refresh any recorded position and size information, also obtaining the span
11.8 - of the mapped region used to access the file or pipe. */
11.9 + /* Refresh any recorded position information, also obtaining the span
11.10 + of the mapped region used to access the file or pipe, along with updated
11.11 + size information. To support the acquisition of files or pipes, the
11.12 + object flags describing the object are returned. */
11.13
11.14 - [opcode(16)] void refresh(out offset_t position, out offset_t size,
11.15 - out offset_t region_size);
11.16 + [opcode(16)] void refresh(out offset_t position, out offset_t start_pos,
11.17 + out offset_t end_pos, out offset_t size,
11.18 + out object_flags_t object_flags);
11.19 };