1.1 --- a/libexec/lib/src/memory.cc Tue Feb 14 21:05:14 2023 +0100
1.2 +++ b/libexec/lib/src/memory.cc Tue Feb 14 23:36:10 2023 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Support for initialising program memory regions in new tasks.
1.6 *
1.7 - * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 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 @@ -31,12 +31,19 @@
1.13
1.14
1.15
1.16 -/* Obtain the payload as a dataspace. */
1.17 +/* Obtain the payload as a dataspace for a named file. */
1.18
1.19 long exec_get_payload(const char *filename, Payload **payload, bool attach)
1.20 {
1.21 file_t *file = client_open(filename, O_RDONLY);
1.22
1.23 + return exec_get_payload_file(file, payload, attach);
1.24 +}
1.25 +
1.26 +/* Obtain the payload as a dataspace for an existing file. */
1.27 +
1.28 +long exec_get_payload_file(file_t *file, Payload **payload, bool attach)
1.29 +{
1.30 if ((file == NULL) || !client_opened(file))
1.31 return -L4_EIO;
1.32
1.33 @@ -77,7 +84,7 @@
1.34
1.35 if (segment->file_contents())
1.36 {
1.37 - file_t *rfile = client_open(filename, file_opening_flags(segment->region_flags()));
1.38 + file_t *rfile = client_reopen(file, file_opening_flags(segment->region_flags()));
1.39
1.40 if ((rfile == NULL) || !client_opened(rfile))
1.41 {