1.1 --- a/test_files/programs/Makefile Wed Jan 17 00:52:03 2024 +0100
1.2 +++ b/test_files/programs/Makefile Wed Jan 17 00:53:05 2024 +0100
1.3 @@ -1,10 +1,12 @@
1.4 PKGDIR ?= ..
1.5 L4DIR ?= $(PKGDIR)/../../..
1.6
1.7 -TARGET = clip dstest_exec_payload ls
1.8 +TARGET = cat clip dstest_exec_payload ls
1.9
1.10 MODE = static
1.11
1.12 +SRC_C_cat = cat.c
1.13 +
1.14 SRC_C_clip = clip.c
1.15
1.16 SRC_C_dstest_exec_payload = dstest_exec_payload.c
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/test_files/programs/cat.c Wed Jan 17 00:53:05 2024 +0100
2.3 @@ -0,0 +1,90 @@
2.4 +/*
2.5 + * Show concatenated filesystem object contents using the client library.
2.6 + *
2.7 + * This should eventually use C library functions instead of client library
2.8 + * functions.
2.9 + *
2.10 + * Copyright (C) 2024 Paul Boddie <paul@boddie.org.uk>
2.11 + *
2.12 + * This program is free software; you can redistribute it and/or
2.13 + * modify it under the terms of the GNU General Public License as
2.14 + * published by the Free Software Foundation; either version 2 of
2.15 + * the License, or (at your option) any later version.
2.16 + *
2.17 + * This program is distributed in the hope that it will be useful,
2.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.20 + * GNU General Public License for more details.
2.21 + *
2.22 + * You should have received a copy of the GNU General Public License
2.23 + * along with this program; if not, write to the Free Software
2.24 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
2.25 + * Boston, MA 02110-1301, USA
2.26 + */
2.27 +
2.28 +#include <stdio.h>
2.29 +
2.30 +
2.31 +
2.32 +/* NOTE: For inclusion in the C library: stream acquisition and access. */
2.33 +
2.34 +#include <fsclient/client.h>
2.35 +#include <systypes/env.h>
2.36 +#include <systypes/fcntl.h>
2.37 +
2.38 +file_t *output;
2.39 +
2.40 +
2.41 +
2.42 +/* Transfer size for communication. */
2.43 +
2.44 +static const offset_t TO_TRANSFER = 1024;
2.45 +
2.46 +
2.47 +
2.48 +/* Show an object from the filesystem. */
2.49 +
2.50 +static int show_object(const char *path)
2.51 +{
2.52 + char *buffer[TO_TRANSFER];
2.53 + file_t *file = client_open(path, O_RDONLY);
2.54 + offset_t nread;
2.55 +
2.56 + if (!client_opened(file))
2.57 + return 1;
2.58 +
2.59 + while ((nread = client_read(file, buffer, TO_TRANSFER)))
2.60 + client_write(output, buffer, nread);
2.61 +
2.62 + client_close(file);
2.63 +
2.64 + return 0;
2.65 +}
2.66 +
2.67 +/* List objects in the filesystem image. */
2.68 +
2.69 +int main(int argc, char *argv[])
2.70 +{
2.71 + int i;
2.72 +
2.73 + /* NOTE: For inclusion in the C library: stream acquisition and access. */
2.74 +
2.75 + output = client_get_stream(ENV_OUTPUT_STREAM_NAME, O_WRONLY);
2.76 +
2.77 + /* Show all specified objects. */
2.78 +
2.79 + for (i = 1; i < argc; i++)
2.80 + {
2.81 + if (show_object(argv[i]))
2.82 + return 1;
2.83 + }
2.84 +
2.85 + /* NOTE: For inclusion in the C library: stream acquisition and access. */
2.86 +
2.87 + client_flush(output);
2.88 +
2.89 + return 0;
2.90 +}
2.91 +
2.92 +/* vim: tabstop=4 expandtab shiftwidth=4
2.93 +*/
3.1 --- a/test_files/programs/ls.c Wed Jan 17 00:52:03 2024 +0100
3.2 +++ b/test_files/programs/ls.c Wed Jan 17 00:53:05 2024 +0100
3.3 @@ -121,7 +121,7 @@
3.4 return 0;
3.5 }
3.6
3.7 -/* List an object in the filesystem image. */
3.8 +/* List an object in the filesystem. */
3.9
3.10 static int list_object(const char *path)
3.11 {
3.12 @@ -144,7 +144,7 @@
3.13 return 0;
3.14 }
3.15
3.16 -/* List objects in the filesystem image. */
3.17 +/* List objects in the filesystem. */
3.18
3.19 int main(int argc, char *argv[])
3.20 {