1.1 --- a/conf/dstest_fsaccess.cfg Mon Jan 15 00:05:01 2024 +0100
1.2 +++ b/conf/dstest_fsaccess.cfg Mon Jan 15 01:18:41 2024 +0100
1.3 @@ -37,16 +37,30 @@
1.4 },
1.5 log = { "ext2svr", "y" },
1.6 },
1.7 - "rom/ext2_server", "blockserver", "rom/e2test.fs", "10", "fsserver");
1.8 + "rom/ext2_server", "blockserver", "rom/e2test.fs", "20", "fsserver");
1.9
1.10 -- Obtain user filesystems with umask 0022 (18).
1.11
1.12 local open_for_user = 6;
1.13 local ext2server_paulb = L4.cast(L4.Proto.Factory, ext2server):create(open_for_user, 1000, 1000, 18);
1.14
1.15 +local process_server = l:new_channel();
1.16 +
1.17 l:startv({
1.18 caps = {
1.19 fsserver = ext2server_paulb,
1.20 + prserver = process_server:svr(),
1.21 + jdb = L4.Env.jdb, -- to set the server name
1.22 + },
1.23 + log = { "process", "y" },
1.24 + },
1.25 + "rom/process_server", "home/paulb/exec_region_mapper");
1.26 +
1.27 +l:startv({
1.28 + caps = {
1.29 + fsserver = ext2server_paulb,
1.30 + pipeserver = pipe_server,
1.31 + prserver = process_server,
1.32 },
1.33 log = { "client", "g" },
1.34 },
2.1 --- a/conf/dstest_fsaccess.list Mon Jan 15 00:05:01 2024 +0100
2.2 +++ b/conf/dstest_fsaccess.list Mon Jan 15 01:18:41 2024 +0100
2.3 @@ -9,6 +9,7 @@
2.4 module ext2_server
2.5 module block_server
2.6 module pipe_server
2.7 +module process_server
2.8 module lib4re-c.so
2.9 module lib4re-c-util.so
2.10 module lib4re.so
3.1 --- a/conf/dstest_fsaccess_stdin.cfg Mon Jan 15 00:05:01 2024 +0100
3.2 +++ b/conf/dstest_fsaccess_stdin.cfg Mon Jan 15 01:18:41 2024 +0100
3.3 @@ -37,19 +37,32 @@
3.4 },
3.5 log = { "ext2svr", "y" },
3.6 },
3.7 - "rom/ext2_server", "blockserver", "rom/e2test.fs", "10", "fsserver");
3.8 + "rom/ext2_server", "blockserver", "rom/e2test.fs", "20", "fsserver");
3.9
3.10 -- Obtain user filesystems with umask 0022 (18).
3.11
3.12 local open_for_user = 6;
3.13 local ext2server_paulb = L4.cast(L4.Proto.Factory, ext2server):create(open_for_user, 1000, 1000, 18);
3.14
3.15 +local process_server = l:new_channel();
3.16 +
3.17 +l:startv({
3.18 + caps = {
3.19 + fsserver = ext2server_paulb,
3.20 + prserver = process_server:svr(),
3.21 + jdb = L4.Env.jdb, -- to set the server name
3.22 + },
3.23 + log = { "process", "y" },
3.24 + },
3.25 + "rom/process_server", "home/paulb/exec_region_mapper");
3.26 +
3.27 l:startv({
3.28 log = L4.Env.log,
3.29 caps = {
3.30 fsserver = ext2server_paulb,
3.31 + pipeserver = pipe_server,
3.32 + prserver = process_server,
3.33 },
3.34 - -- log = { "client", "g" },
3.35 },
3.36 -- program, options, operation involving a script file
3.37 "rom/fsaccess", "-m", "0022", "script", "-");
4.1 --- a/conf/dstest_fsaccess_stdin.list Mon Jan 15 00:05:01 2024 +0100
4.2 +++ b/conf/dstest_fsaccess_stdin.list Mon Jan 15 01:18:41 2024 +0100
4.3 @@ -9,6 +9,7 @@
4.4 module ext2_server
4.5 module block_server
4.6 module pipe_server
4.7 +module process_server
4.8 module lib4re-c.so
4.9 module lib4re-c-util.so
4.10 module lib4re.so
5.1 --- a/fsaccess/Control Mon Jan 15 00:05:01 2024 +0100
5.2 +++ b/fsaccess/Control Mon Jan 15 01:18:41 2024 +0100
5.3 @@ -1,3 +1,3 @@
5.4 -requires: libc libipc libfsclient libmem libext2fs libext2fs_blockserver libe2access_blockserver
5.5 +requires: libc libipc libfsclient libmem libext2fs libext2fs_blockserver libe2access_blockserver fsservers
5.6 provides: fsaccess
5.7 maintainer: paul@boddie.org.uk
6.1 --- a/fsaccess/Makefile Mon Jan 15 00:05:01 2024 +0100
6.2 +++ b/fsaccess/Makefile Mon Jan 15 01:18:41 2024 +0100
6.3 @@ -8,7 +8,7 @@
6.4 SRC_C = \
6.5 file.c fsaccess.c input.c session.c ops.c \
6.6 op_copy_in.c op_list_objects.c op_make_dirs.c op_remove.c \
6.7 - op_script.c op_stat_objects.c
6.8 + op_run.c op_script.c op_stat_objects.c
6.9
6.10 REQUIRES_LIBS = l4re_c-util libfsclient libmem libipc libsystypes libe2access libe2access_blockserver
6.11
7.1 --- a/fsaccess/fsaccess.c Mon Jan 15 00:05:01 2024 +0100
7.2 +++ b/fsaccess/fsaccess.c Mon Jan 15 01:18:41 2024 +0100
7.3 @@ -51,6 +51,9 @@
7.4 Script operations:\n\
7.5 \n\
7.6 script Read operations from a script file (or stdin)\n\
7.7 +Execution operations:\n\
7.8 +\n\
7.9 + run Run a program from the filesystem\n\
7.10 ";
7.11
7.12 /* Operations exposed by the program. */
7.13 @@ -61,6 +64,7 @@
7.14 {"mkdir", make_dirs},
7.15 {"rm", remove_non_dirs},
7.16 {"rmdir", remove_dirs},
7.17 + {"run", run_program},
7.18 {"script", run_script},
7.19 {"stat", stat_objects},
7.20 {NULL, NULL},
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/fsaccess/op_run.c Mon Jan 15 01:18:41 2024 +0100
8.3 @@ -0,0 +1,105 @@
8.4 +/*
8.5 + * Run a program residing in the filesystem.
8.6 + *
8.7 + * Copyright (C) 2022, 2023, 2024 Paul Boddie <paul@boddie.org.uk>
8.8 + *
8.9 + * This program is free software; you can redistribute it and/or
8.10 + * modify it under the terms of the GNU General Public License as
8.11 + * published by the Free Software Foundation; either version 2 of
8.12 + * the License, or (at your option) any later version.
8.13 + *
8.14 + * This program is distributed in the hope that it will be useful,
8.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.17 + * GNU General Public License for more details.
8.18 + *
8.19 + * You should have received a copy of the GNU General Public License
8.20 + * along with this program; if not, write to the Free Software
8.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
8.22 + * Boston, MA 02110-1301, USA
8.23 + */
8.24 +
8.25 +#include <l4/sys/err.h>
8.26 +
8.27 +#include <fsclient/client.h>
8.28 +#include <fsclient/process.h>
8.29 +#include <systypes/fcntl.h>
8.30 +#include <systypes/format.h>
8.31 +
8.32 +#include <stdio.h>
8.33 +
8.34 +#include "ops.h"
8.35 +
8.36 +
8.37 +
8.38 +/* Transfer size for communication. */
8.39 +
8.40 +static const offset_t TO_TRANSFER = 1024;
8.41 +
8.42 +
8.43 +
8.44 +/* Run the given program. */
8.45 +
8.46 +int run_program(int argc, char *argv[])
8.47 +{
8.48 + char buffer[TO_TRANSFER];
8.49 + process_t *process;
8.50 + file_t *reader, *writer;
8.51 + notify_flags_t flags;
8.52 + notify_values_t values;
8.53 + long err;
8.54 +
8.55 + /* Create a pipe for process output. */
8.56 +
8.57 + err = client_pipe(&reader, &writer, 0);
8.58 +
8.59 + if (err)
8.60 + {
8.61 + printf("Could not obtain pipe: %s\n", l4sys_errtostr(err));
8.62 + return 1;
8.63 + }
8.64 +
8.65 + /* Start the process. */
8.66 +
8.67 + err = process_spawn(argc, (const char **) argv, writer, &process);
8.68 +
8.69 + if (err)
8.70 + {
8.71 + printf("Could not start process: %s\n", l4sys_errtostr(err));
8.72 + return 1;
8.73 + }
8.74 +
8.75 + printf("Finished program initiation.\n");
8.76 +
8.77 + /* Release the writing end of the pipe. */
8.78 +
8.79 + client_close(writer);
8.80 +
8.81 + /* Read until the pipe yields no more data. */
8.82 +
8.83 + while (1)
8.84 + {
8.85 + offset_t nread = client_read(reader, buffer, TO_TRANSFER);
8.86 +
8.87 + if (nread)
8.88 + fwrite(buffer, sizeof(char), nread, stdout);
8.89 + else
8.90 + break;
8.91 + }
8.92 +
8.93 + /* Close the pipe and obtain the process state. */
8.94 +
8.95 + client_close(reader);
8.96 +
8.97 + err = process_wait(process, &flags, &values);
8.98 +
8.99 + printf("End process (flags %" pFMTnotify_flags "x values: %ld, %ld)\n", flags, values.sig, values.val);
8.100 +
8.101 + if (err)
8.102 + return 1;
8.103 +
8.104 + return 0;
8.105 +}
8.106 +
8.107 +/* vim: tabstop=2 expandtab shiftwidth=2
8.108 +*/
9.1 --- a/fsaccess/op_script.c Mon Jan 15 00:05:01 2024 +0100
9.2 +++ b/fsaccess/op_script.c Mon Jan 15 01:18:41 2024 +0100
9.3 @@ -33,7 +33,7 @@
9.4
9.5 /* Maximum number of arguments in scripts. */
9.6
9.7 -const int MAX_ARGS = 32;
9.8 +static const int MAX_ARGS = 32;
9.9
9.10
9.11
10.1 --- a/fsaccess/ops.h Mon Jan 15 00:05:01 2024 +0100
10.2 +++ b/fsaccess/ops.h Mon Jan 15 01:18:41 2024 +0100
10.3 @@ -1,7 +1,7 @@
10.4 /*
10.5 * Operations and their invocation.
10.6 *
10.7 - * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
10.8 + * Copyright (C) 2022, 2024 Paul Boddie <paul@boddie.org.uk>
10.9 *
10.10 * This program is free software; you can redistribute it and/or
10.11 * modify it under the terms of the GNU General Public License as
10.12 @@ -49,6 +49,7 @@
10.13 int make_dirs(int argc, char *argv[]);
10.14 int remove_dirs(int argc, char *argv[]);
10.15 int remove_non_dirs(int argc, char *argv[]);
10.16 +int run_program(int argc, char *argv[]);
10.17 int run_script(int argc, char *argv[]);
10.18 int stat_objects(int argc, char *argv[]);
10.19