1.1 --- a/libfsserver/include/fsserver/opener_context_resource.h Mon Feb 27 14:46:13 2023 +0100
1.2 +++ b/libfsserver/include/fsserver/opener_context_resource.h Tue Feb 28 22:35:25 2023 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * A context resource offering support for opening files.
1.6 *
1.7 - * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -49,10 +49,6 @@
1.13 void *interface()
1.14 { return static_cast<OpenerContextObject *>(this); }
1.15
1.16 - /* Data access methods. */
1.17 -
1.18 - char *get_path(offset_t offset=0);
1.19 -
1.20 /* Opener context interface methods. */
1.21
1.22 long mkdir(sys_mode_t mode);
2.1 --- a/libfsserver/include/fsserver/simple_pager.h Mon Feb 27 14:46:13 2023 +0100
2.2 +++ b/libfsserver/include/fsserver/simple_pager.h Tue Feb 28 22:35:25 2023 +0100
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * A simple pager exposing a single memory region.
2.6 *
2.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -41,6 +41,10 @@
2.13
2.14 void close();
2.15
2.16 + /* Data access methods. */
2.17 +
2.18 + char *get_string(offset_t offset=0);
2.19 +
2.20 /* Paging methods. */
2.21
2.22 long map(offset_t offset, map_address_t hot_spot, map_flags_t flags, l4_snd_fpage_t *region);
3.1 --- a/libfsserver/lib/files/opener_context_resource.cc Mon Feb 27 14:46:13 2023 +0100
3.2 +++ b/libfsserver/lib/files/opener_context_resource.cc Tue Feb 28 22:35:25 2023 +0100
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * A context resource offering support for opening files.
3.6 *
3.7 - * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -43,28 +43,11 @@
3.13
3.14
3.15
3.16 -/* Data access methods. */
3.17 -
3.18 -char *OpenerContextResource::get_path(offset_t offset)
3.19 -{
3.20 - char *buffer = _region->read(offset);
3.21 - offset_t size = _region->size();
3.22 -
3.23 - /* Confine the path to the limit of the buffer. */
3.24 -
3.25 - if ((buffer != NULL) && (strnlen(buffer, size) < size))
3.26 - return buffer;
3.27 - else
3.28 - return NULL;
3.29 -}
3.30 -
3.31 -
3.32 -
3.33 /* Opener context interface methods. */
3.34
3.35 long OpenerContextResource::mkdir(sys_mode_t mode)
3.36 {
3.37 - char *path = get_path();
3.38 + char *path = get_string();
3.39
3.40 if (path == NULL)
3.41 return -L4_EINVAL;
3.42 @@ -75,7 +58,7 @@
3.43 long OpenerContextResource::open(flags_t flags, offset_t *size,
3.44 l4_cap_idx_t *file, object_flags_t *object_flags)
3.45 {
3.46 - char *path = get_path();
3.47 + char *path = get_string();
3.48
3.49 if (path == NULL)
3.50 return -L4_EINVAL;
3.51 @@ -85,7 +68,7 @@
3.52
3.53 long OpenerContextResource::remove()
3.54 {
3.55 - char *path = get_path();
3.56 + char *path = get_string();
3.57
3.58 if (path == NULL)
3.59 return -L4_EINVAL;
3.60 @@ -97,12 +80,12 @@
3.61 {
3.62 char *source, *target;
3.63
3.64 - source = get_path();
3.65 + source = get_string();
3.66
3.67 if (source == NULL)
3.68 return -L4_EINVAL;
3.69
3.70 - target = get_path(strlen(source) + 1);
3.71 + target = get_string(strlen(source) + 1);
3.72
3.73 if (target == NULL)
3.74 return -L4_EINVAL;
3.75 @@ -112,7 +95,7 @@
3.76
3.77 long OpenerContextResource::stat()
3.78 {
3.79 - char *path = get_path();
3.80 + char *path = get_string();
3.81
3.82 if (path == NULL)
3.83 return -L4_EINVAL;
4.1 --- a/libfsserver/lib/generic/simple_pager.cc Mon Feb 27 14:46:13 2023 +0100
4.2 +++ b/libfsserver/lib/generic/simple_pager.cc Tue Feb 28 22:35:25 2023 +0100
4.3 @@ -1,7 +1,7 @@
4.4 /*
4.5 * A simple pager exposing a single memory region.
4.6 *
4.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
4.8 + * Copyright (C) 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
4.9 *
4.10 * This program is free software; you can redistribute it and/or
4.11 * modify it under the terms of the GNU General Public License as
4.12 @@ -23,6 +23,8 @@
4.13
4.14 #include <mem/memory_incremental.h>
4.15
4.16 +#include <string.h>
4.17 +
4.18 #include "dataspace_server.h"
4.19 #include "ipc.h"
4.20 #include "simple_pager.h"
4.21 @@ -48,6 +50,25 @@
4.22 }
4.23 }
4.24
4.25 +
4.26 +
4.27 +/* Data access methods. */
4.28 +
4.29 +char *SimplePager::get_string(offset_t offset)
4.30 +{
4.31 + char *buffer = _region->read(offset);
4.32 + offset_t size = _region->size();
4.33 +
4.34 + /* Confine the path to the limit of the buffer. */
4.35 +
4.36 + if ((buffer != NULL) && (strnlen(buffer, size) < size))
4.37 + return buffer;
4.38 + else
4.39 + return NULL;
4.40 +}
4.41 +
4.42 +
4.43 +
4.44 /* Map a flexpage corresponding to the dataspace 'offset' involving a 'hot_spot'
4.45 (flexpage offset). */
4.46