1.1 --- a/Makefile Tue Oct 22 23:07:50 2019 +0200
1.2 +++ b/Makefile Wed Oct 23 15:41:13 2019 +0200
1.3 @@ -2,14 +2,14 @@
1.4 L4DIR ?= $(PKGDIR)/../..
1.5
1.6 TARGET = \
1.7 - test_newlib \
1.8 + test_newlib_fd_ops \
1.9 test_newlib_fstat \
1.10 test_newlib_lseek \
1.11 test_newlib_malloc \
1.12 test_newlib_posix_memalign \
1.13 test_newlib_stat \
1.14
1.15 -SRC_C_test_newlib = crt0.c debug.c minimal.c
1.16 +SRC_C_test_newlib_fd_ops = crt0.c debug.c fd_ops.c
1.17 SRC_C_test_newlib_fstat = crt0.c debug.c fstat.c
1.18 SRC_C_test_newlib_lseek = crt0.c debug.c lseek.c
1.19 SRC_C_test_newlib_malloc = crt0.c debug.c malloc.c
2.1 --- a/conf/test_newlib.cfg Tue Oct 22 23:07:50 2019 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,43 +0,0 @@
2.4 --- vim:set ft=lua:
2.5 -
2.6 -local L4 = require("L4");
2.7 -
2.8 -local l = L4.default_loader;
2.9 -
2.10 -local block_root = l:new_channel();
2.11 -
2.12 -l:startv({
2.13 - caps = {
2.14 - block = block_root:svr(),
2.15 - },
2.16 - log = { "block_root", "r" },
2.17 - },
2.18 - "rom/blockserver", "rom/e2test.fs", "4");
2.19 -
2.20 --- Root filesystem.
2.21 -
2.22 -local fs_root = l:new_channel();
2.23 -
2.24 -l:startv({
2.25 - caps = {
2.26 - block = block_root,
2.27 - export = fs_root:svr(),
2.28 - },
2.29 - log = { "fs_root", "y" },
2.30 - },
2.31 - "rom/e2fsserver", "block", "4");
2.32 -
2.33 --- Obtain user filesystems with umask 0022 (18).
2.34 -
2.35 -local getuserfs = 6;
2.36 -local fs_paulb = L4.cast(L4.Proto.Factory, fs_root):create(getuserfs, 1000, 1000, 18);
2.37 -
2.38 --- Client programs.
2.39 -
2.40 -l:startv({
2.41 - caps = {
2.42 - fs = fs_paulb,
2.43 - },
2.44 - log = { "client", "g" },
2.45 - },
2.46 - "rom/test_newlib", "home/paulb/test.txt");
3.1 --- a/conf/test_newlib.list Tue Oct 22 23:07:50 2019 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,37 +0,0 @@
3.4 -entry test_newlib
3.5 -roottask moe rom/test_newlib.cfg
3.6 -module test_newlib.cfg
3.7 -module e2test.fs
3.8 -module ned
3.9 -module l4re
3.10 -module test_newlib
3.11 -module e2fsserver
3.12 -module blockserver
3.13 -module lib4re-c.so
3.14 -module lib4re-c-util.so
3.15 -module lib4re.so
3.16 -module lib4re-util.so
3.17 -module libblkid.so
3.18 -module libc_be_l4refile.so
3.19 -module libc_be_l4re.so
3.20 -module libc_be_socket_noop.so
3.21 -module libc_support_misc.so
3.22 -module libdl.so
3.23 -module libe2access.so
3.24 -module libe2p.so
3.25 -module libet.so
3.26 -module libext2fs_blockserver.so
3.27 -module libext2fs.so
3.28 -module libfsclient.so
3.29 -module libfsserver.so
3.30 -module libipc.so
3.31 -module libl4sys-direct.so
3.32 -module libl4sys.so
3.33 -module libl4util.so
3.34 -module libld-l4.so
3.35 -module libpthread.so
3.36 -module libstdc++.so
3.37 -module libsupc++.so
3.38 -module libsupport.so
3.39 -module libuc_c.so
3.40 -module libuuid.so
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/conf/test_newlib_fd_ops.cfg Wed Oct 23 15:41:13 2019 +0200
4.3 @@ -0,0 +1,43 @@
4.4 +-- vim:set ft=lua:
4.5 +
4.6 +local L4 = require("L4");
4.7 +
4.8 +local l = L4.default_loader;
4.9 +
4.10 +local block_root = l:new_channel();
4.11 +
4.12 +l:startv({
4.13 + caps = {
4.14 + block = block_root:svr(),
4.15 + },
4.16 + log = { "block_root", "r" },
4.17 + },
4.18 + "rom/blockserver", "rom/e2test.fs", "4");
4.19 +
4.20 +-- Root filesystem.
4.21 +
4.22 +local fs_root = l:new_channel();
4.23 +
4.24 +l:startv({
4.25 + caps = {
4.26 + block = block_root,
4.27 + export = fs_root:svr(),
4.28 + },
4.29 + log = { "fs_root", "y" },
4.30 + },
4.31 + "rom/e2fsserver", "block", "4");
4.32 +
4.33 +-- Obtain user filesystems with umask 0022 (18).
4.34 +
4.35 +local getuserfs = 6;
4.36 +local fs_paulb = L4.cast(L4.Proto.Factory, fs_root):create(getuserfs, 1000, 1000, 18);
4.37 +
4.38 +-- Client programs.
4.39 +
4.40 +l:startv({
4.41 + caps = {
4.42 + fs = fs_paulb,
4.43 + },
4.44 + log = { "client", "g" },
4.45 + },
4.46 + "rom/test_newlib_fd_ops", "home/paulb/test.txt");
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/conf/test_newlib_fd_ops.list Wed Oct 23 15:41:13 2019 +0200
5.3 @@ -0,0 +1,37 @@
5.4 +entry test_newlib_fd_ops
5.5 +roottask moe rom/test_newlib_fd_ops.cfg
5.6 +module test_newlib_fd_ops.cfg
5.7 +module e2test.fs
5.8 +module ned
5.9 +module l4re
5.10 +module test_newlib_fd_ops
5.11 +module e2fsserver
5.12 +module blockserver
5.13 +module lib4re-c.so
5.14 +module lib4re-c-util.so
5.15 +module lib4re.so
5.16 +module lib4re-util.so
5.17 +module libblkid.so
5.18 +module libc_be_l4refile.so
5.19 +module libc_be_l4re.so
5.20 +module libc_be_socket_noop.so
5.21 +module libc_support_misc.so
5.22 +module libdl.so
5.23 +module libe2access.so
5.24 +module libe2p.so
5.25 +module libet.so
5.26 +module libext2fs_blockserver.so
5.27 +module libext2fs.so
5.28 +module libfsclient.so
5.29 +module libfsserver.so
5.30 +module libipc.so
5.31 +module libl4sys-direct.so
5.32 +module libl4sys.so
5.33 +module libl4util.so
5.34 +module libld-l4.so
5.35 +module libpthread.so
5.36 +module libstdc++.so
5.37 +module libsupc++.so
5.38 +module libsupport.so
5.39 +module libuc_c.so
5.40 +module libuuid.so
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/fd_ops.c Wed Oct 23 15:41:13 2019 +0200
6.3 @@ -0,0 +1,69 @@
6.4 +#include <fcntl.h>
6.5 +#include <string.h>
6.6 +#include <unistd.h>
6.7 +
6.8 +#include "debug.h"
6.9 +
6.10 +/* Messages. */
6.11 +
6.12 +char message[] = "Hello file!\n";
6.13 +
6.14 +/* Definitions from fcntl.h and fcntl-linux.h. */
6.15 +
6.16 +#define O_CREAT_LINUX 0x0100
6.17 +
6.18 +
6.19 +
6.20 +/* Main program. */
6.21 +
6.22 +int main(int argc, char *argv[], char *envp[])
6.23 +{
6.24 + int fd;
6.25 + char buffer[100];
6.26 + int available;
6.27 +
6.28 + fd = open(argv[1], O_CREAT_LINUX | O_RDWR);
6.29 +
6.30 + if (fd == -1)
6.31 + {
6.32 + debug("Failed to open file!\n");
6.33 + return 1;
6.34 + }
6.35 +
6.36 + /* Write and then read back. */
6.37 +
6.38 + if (write(fd, message, strlen(message)) == -1)
6.39 + {
6.40 + debug("Failed to write to file!\n");
6.41 + return 1;
6.42 + }
6.43 +
6.44 + if (close(fd) == -1)
6.45 + {
6.46 + debug("Failed to close file!\n");
6.47 + return 1;
6.48 + }
6.49 +
6.50 + fd = open(argv[1], O_RDWR);
6.51 +
6.52 + if (fd == -1)
6.53 + {
6.54 + debug("Failed to open file!\n");
6.55 + return 1;
6.56 + }
6.57 +
6.58 + available = read(fd, buffer, 100);
6.59 +
6.60 + if (available == -1)
6.61 + debug("Failed to read file!\n");
6.62 + else if (!available)
6.63 + debug("Nothing read.\n");
6.64 + else
6.65 + debug_len(buffer, available);
6.66 +
6.67 + /* Finish off. */
6.68 +
6.69 + debug("At end of program!\n");
6.70 +
6.71 + return 0;
6.72 +}
7.1 --- a/minimal.c Tue Oct 22 23:07:50 2019 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,69 +0,0 @@
7.4 -#include <fcntl.h>
7.5 -#include <string.h>
7.6 -#include <unistd.h>
7.7 -
7.8 -#include "debug.h"
7.9 -
7.10 -/* Messages. */
7.11 -
7.12 -char message[] = "Hello file!\n";
7.13 -
7.14 -/* Definitions from fcntl.h and fcntl-linux.h. */
7.15 -
7.16 -#define O_CREAT_LINUX 0x0100
7.17 -
7.18 -
7.19 -
7.20 -/* Main program. */
7.21 -
7.22 -int main(int argc, char *argv[], char *envp[])
7.23 -{
7.24 - int fd;
7.25 - char buffer[100];
7.26 - int available;
7.27 -
7.28 - fd = open(argv[1], O_CREAT_LINUX | O_RDWR);
7.29 -
7.30 - if (fd == -1)
7.31 - {
7.32 - debug("Failed to open file!\n");
7.33 - return 1;
7.34 - }
7.35 -
7.36 - /* Write and then read back. */
7.37 -
7.38 - if (write(fd, message, strlen(message)) == -1)
7.39 - {
7.40 - debug("Failed to write to file!\n");
7.41 - return 1;
7.42 - }
7.43 -
7.44 - if (close(fd) == -1)
7.45 - {
7.46 - debug("Failed to close file!\n");
7.47 - return 1;
7.48 - }
7.49 -
7.50 - fd = open(argv[1], O_RDWR);
7.51 -
7.52 - if (fd == -1)
7.53 - {
7.54 - debug("Failed to open file!\n");
7.55 - return 1;
7.56 - }
7.57 -
7.58 - available = read(fd, buffer, 100);
7.59 -
7.60 - if (available == -1)
7.61 - debug("Failed to read file!\n");
7.62 - else if (!available)
7.63 - debug("Nothing read.\n");
7.64 - else
7.65 - debug_len(buffer, available);
7.66 -
7.67 - /* Finish off. */
7.68 -
7.69 - debug("At end of program!\n");
7.70 -
7.71 - return 0;
7.72 -}