1.1 --- a/conf/dstest_block.cfg Thu Sep 01 21:40:39 2022 +0200 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,23 +0,0 @@ 1.4 --- vim:set ft=lua: 1.5 - 1.6 -local L4 = require("L4"); 1.7 - 1.8 -local l = L4.default_loader; 1.9 - 1.10 -local server = l:new_channel(); 1.11 - 1.12 -l:startv({ 1.13 - caps = { 1.14 - server = server:svr(), 1.15 - }, 1.16 - log = { "server", "r" }, 1.17 - }, 1.18 - "rom/block_server", "10"); 1.19 - 1.20 -l:startv({ 1.21 - caps = { 1.22 - server = server, 1.23 - }, 1.24 - log = { "client", "g" }, 1.25 - }, 1.26 - "rom/dstest_block_client", "rom/dstest_block.cfg", 1024, 1024);
2.1 --- a/conf/dstest_block.list Thu Sep 01 21:40:39 2022 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,25 +0,0 @@ 2.4 -entry dstest_block 2.5 -roottask moe rom/dstest_block.cfg 2.6 -module dstest_block.cfg 2.7 -module l4re 2.8 -module ned 2.9 -module dstest_block_client 2.10 -module block_server 2.11 -module lib4re-c.so 2.12 -module lib4re-c-util.so 2.13 -module lib4re.so 2.14 -module lib4re-util.so 2.15 -module libc_be_l4refile.so 2.16 -module libc_be_l4re.so 2.17 -module libc_be_socket_noop.so 2.18 -module libc_support_misc.so 2.19 -module libdl.so 2.20 -module libipc.so 2.21 -module libl4sys-direct.so 2.22 -module libl4sys.so 2.23 -module libl4util.so 2.24 -module libld-l4.so 2.25 -module libpthread.so 2.26 -module libstdc++.so 2.27 -module libsupc++.so 2.28 -module libuc_c.so
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/conf/dstest_block_client.cfg Thu Sep 01 21:52:41 2022 +0200 3.3 @@ -0,0 +1,23 @@ 3.4 +-- vim:set ft=lua: 3.5 + 3.6 +local L4 = require("L4"); 3.7 + 3.8 +local l = L4.default_loader; 3.9 + 3.10 +local server = l:new_channel(); 3.11 + 3.12 +l:startv({ 3.13 + caps = { 3.14 + server = server:svr(), 3.15 + }, 3.16 + log = { "server", "r" }, 3.17 + }, 3.18 + "rom/block_server", "10"); 3.19 + 3.20 +l:startv({ 3.21 + caps = { 3.22 + server = server, 3.23 + }, 3.24 + log = { "client", "g" }, 3.25 + }, 3.26 + "rom/dstest_block_client", "rom/dstest_block_client.cfg", 1024, 1024);
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/conf/dstest_block_client.list Thu Sep 01 21:52:41 2022 +0200 4.3 @@ -0,0 +1,25 @@ 4.4 +entry dstest_block_client 4.5 +roottask moe rom/dstest_block_client.cfg 4.6 +module dstest_block_client.cfg 4.7 +module l4re 4.8 +module ned 4.9 +module dstest_block_client 4.10 +module block_server 4.11 +module lib4re-c.so 4.12 +module lib4re-c-util.so 4.13 +module lib4re.so 4.14 +module lib4re-util.so 4.15 +module libc_be_l4refile.so 4.16 +module libc_be_l4re.so 4.17 +module libc_be_socket_noop.so 4.18 +module libc_support_misc.so 4.19 +module libdl.so 4.20 +module libipc.so 4.21 +module libl4sys-direct.so 4.22 +module libl4sys.so 4.23 +module libl4util.so 4.24 +module libld-l4.so 4.25 +module libpthread.so 4.26 +module libstdc++.so 4.27 +module libsupc++.so 4.28 +module libuc_c.so
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/conf/dstest_block_client_simple.cfg Thu Sep 01 21:52:41 2022 +0200 5.3 @@ -0,0 +1,23 @@ 5.4 +-- vim:set ft=lua: 5.5 + 5.6 +local L4 = require("L4"); 5.7 + 5.8 +local l = L4.default_loader; 5.9 + 5.10 +local server = l:new_channel(); 5.11 + 5.12 +l:startv({ 5.13 + caps = { 5.14 + server = server:svr(), 5.15 + }, 5.16 + log = { "server", "r" }, 5.17 + }, 5.18 + "rom/block_server", "10"); 5.19 + 5.20 +l:startv({ 5.21 + caps = { 5.22 + server = server, 5.23 + }, 5.24 + log = { "client", "g" }, 5.25 + }, 5.26 + "rom/dstest_block_client_simple", "rom/dstest_block_client_simple.cfg");
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/conf/dstest_block_client_simple.list Thu Sep 01 21:52:41 2022 +0200 6.3 @@ -0,0 +1,25 @@ 6.4 +entry dstest_block_client_simple 6.5 +roottask moe rom/dstest_block_client_simple.cfg 6.6 +module dstest_block_client_simple.cfg 6.7 +module l4re 6.8 +module ned 6.9 +module dstest_block_client_simple 6.10 +module block_server 6.11 +module lib4re-c.so 6.12 +module lib4re-c-util.so 6.13 +module lib4re.so 6.14 +module lib4re-util.so 6.15 +module libc_be_l4refile.so 6.16 +module libc_be_l4re.so 6.17 +module libc_be_socket_noop.so 6.18 +module libc_support_misc.so 6.19 +module libdl.so 6.20 +module libipc.so 6.21 +module libl4sys-direct.so 6.22 +module libl4sys.so 6.23 +module libl4util.so 6.24 +module libld-l4.so 6.25 +module libpthread.so 6.26 +module libstdc++.so 6.27 +module libsupc++.so 6.28 +module libuc_c.so
7.1 --- a/conf/dstest_block_simple.cfg Thu Sep 01 21:40:39 2022 +0200 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,23 +0,0 @@ 7.4 --- vim:set ft=lua: 7.5 - 7.6 -local L4 = require("L4"); 7.7 - 7.8 -local l = L4.default_loader; 7.9 - 7.10 -local server = l:new_channel(); 7.11 - 7.12 -l:startv({ 7.13 - caps = { 7.14 - server = server:svr(), 7.15 - }, 7.16 - log = { "server", "r" }, 7.17 - }, 7.18 - "rom/block_server", "10"); 7.19 - 7.20 -l:startv({ 7.21 - caps = { 7.22 - server = server, 7.23 - }, 7.24 - log = { "client", "g" }, 7.25 - }, 7.26 - "rom/dstest_block_client_simple", "rom/dstest_block_simple.cfg");
8.1 --- a/conf/dstest_block_simple.list Thu Sep 01 21:40:39 2022 +0200 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,25 +0,0 @@ 8.4 -entry dstest_block_simple 8.5 -roottask moe rom/dstest_block_simple.cfg 8.6 -module dstest_block_simple.cfg 8.7 -module l4re 8.8 -module ned 8.9 -module dstest_block_client_simple 8.10 -module block_server 8.11 -module lib4re-c.so 8.12 -module lib4re-c-util.so 8.13 -module lib4re.so 8.14 -module lib4re-util.so 8.15 -module libc_be_l4refile.so 8.16 -module libc_be_l4re.so 8.17 -module libc_be_socket_noop.so 8.18 -module libc_support_misc.so 8.19 -module libdl.so 8.20 -module libipc.so 8.21 -module libl4sys-direct.so 8.22 -module libl4sys.so 8.23 -module libl4util.so 8.24 -module libld-l4.so 8.25 -module libpthread.so 8.26 -module libstdc++.so 8.27 -module libsupc++.so 8.28 -module libuc_c.so
9.1 --- a/conf/dstest_ext2fs.cfg Thu Sep 01 21:40:39 2022 +0200 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,23 +0,0 @@ 9.4 --- vim:set ft=lua: 9.5 - 9.6 -local L4 = require("L4"); 9.7 - 9.8 -local l = L4.default_loader; 9.9 - 9.10 -local blocksvr = l:new_channel(); 9.11 - 9.12 -l:startv({ 9.13 - caps = { 9.14 - server = blocksvr:svr(), 9.15 - }, 9.16 - log = { "blocksvr", "r" }, 9.17 - }, 9.18 - "rom/block_server", "10"); 9.19 - 9.20 -l:startv({ 9.21 - caps = { 9.22 - server = blocksvr, 9.23 - }, 9.24 - log = { "client", "r" }, 9.25 - }, 9.26 - "rom/dstest_ext2fs_client", "server", "rom/e2test.fs");
10.1 --- a/conf/dstest_ext2fs.list Thu Sep 01 21:40:39 2022 +0200 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,26 +0,0 @@ 10.4 -entry dstest_ext2fs 10.5 -roottask moe rom/dstest_ext2fs.cfg 10.6 -module dstest_ext2fs.cfg 10.7 -module e2test.fs 10.8 -module l4re 10.9 -module ned 10.10 -module block_server 10.11 -module dstest_ext2fs_client 10.12 -module lib4re-c.so 10.13 -module lib4re-c-util.so 10.14 -module lib4re.so 10.15 -module lib4re-util.so 10.16 -module libc_be_l4refile.so 10.17 -module libc_be_l4re.so 10.18 -module libc_be_socket_noop.so 10.19 -module libc_support_misc.so 10.20 -module libdl.so 10.21 -module libipc.so 10.22 -module libl4sys-direct.so 10.23 -module libl4sys.so 10.24 -module libl4util.so 10.25 -module libld-l4.so 10.26 -module libpthread.so 10.27 -module libstdc++.so 10.28 -module libsupc++.so 10.29 -module libuc_c.so
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/conf/dstest_ext2fs_client.cfg Thu Sep 01 21:52:41 2022 +0200 11.3 @@ -0,0 +1,23 @@ 11.4 +-- vim:set ft=lua: 11.5 + 11.6 +local L4 = require("L4"); 11.7 + 11.8 +local l = L4.default_loader; 11.9 + 11.10 +local blocksvr = l:new_channel(); 11.11 + 11.12 +l:startv({ 11.13 + caps = { 11.14 + server = blocksvr:svr(), 11.15 + }, 11.16 + log = { "blocksvr", "r" }, 11.17 + }, 11.18 + "rom/block_server", "10"); 11.19 + 11.20 +l:startv({ 11.21 + caps = { 11.22 + server = blocksvr, 11.23 + }, 11.24 + log = { "client", "g" }, 11.25 + }, 11.26 + "rom/dstest_ext2fs_client", "server", "rom/e2test.fs");
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/conf/dstest_ext2fs_client.list Thu Sep 01 21:52:41 2022 +0200 12.3 @@ -0,0 +1,26 @@ 12.4 +entry dstest_ext2fs_client 12.5 +roottask moe rom/dstest_ext2fs_client.cfg 12.6 +module dstest_ext2fs_client.cfg 12.7 +module e2test.fs 12.8 +module l4re 12.9 +module ned 12.10 +module block_server 12.11 +module dstest_ext2fs_client 12.12 +module lib4re-c.so 12.13 +module lib4re-c-util.so 12.14 +module lib4re.so 12.15 +module lib4re-util.so 12.16 +module libc_be_l4refile.so 12.17 +module libc_be_l4re.so 12.18 +module libc_be_socket_noop.so 12.19 +module libc_support_misc.so 12.20 +module libdl.so 12.21 +module libipc.so 12.22 +module libl4sys-direct.so 12.23 +module libl4sys.so 12.24 +module libl4util.so 12.25 +module libld-l4.so 12.26 +module libpthread.so 12.27 +module libstdc++.so 12.28 +module libsupc++.so 12.29 +module libuc_c.so
13.1 --- a/conf/dstest_file.cfg Thu Sep 01 21:40:39 2022 +0200 13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 13.3 @@ -1,40 +0,0 @@ 13.4 --- vim:set ft=lua: 13.5 - 13.6 -local L4 = require("L4"); 13.7 - 13.8 -local l = L4.default_loader; 13.9 - 13.10 -local blocksvr = l:new_channel(); 13.11 - 13.12 -l:startv({ 13.13 - caps = { 13.14 - server = blocksvr:svr(), 13.15 - }, 13.16 - log = { "blocksvr", "r" }, 13.17 - }, 13.18 - "rom/block_server", "10"); 13.19 - 13.20 -local ext2svr = l:new_channel(); 13.21 - 13.22 -l:startv({ 13.23 - caps = { 13.24 - blocksvr = blocksvr, 13.25 - ext2svr = ext2svr:svr(), 13.26 - }, 13.27 - log = { "ext2svr", "y" }, 13.28 - }, 13.29 - "rom/ext2_server", "blocksvr", "rom/e2test.fs", "10", "ext2svr"); 13.30 - 13.31 --- Obtain user filesystems with umask 0022 (18). 13.32 - 13.33 -local open_for_user = 6; 13.34 -local ext2svr_paulb = L4.cast(L4.Proto.Factory, ext2svr):create(open_for_user, 1000, 1000, 18); 13.35 - 13.36 -l:startv({ 13.37 - caps = { 13.38 - server = ext2svr_paulb, 13.39 - }, 13.40 - log = { "client", "g" }, 13.41 - }, 13.42 - -- program, file to create 13.43 - "rom/dstest_file_client", "home/paulb/new file");
14.1 --- a/conf/dstest_file.list Thu Sep 01 21:40:39 2022 +0200 14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 14.3 @@ -1,27 +0,0 @@ 14.4 -entry dstest_file 14.5 -roottask moe rom/dstest_file.cfg 14.6 -module dstest_file.cfg 14.7 -module e2test.fs 14.8 -module l4re 14.9 -module ned 14.10 -module dstest_file_client 14.11 -module ext2_server 14.12 -module block_server 14.13 -module lib4re-c.so 14.14 -module lib4re-c-util.so 14.15 -module lib4re.so 14.16 -module lib4re-util.so 14.17 -module libc_be_l4refile.so 14.18 -module libc_be_l4re.so 14.19 -module libc_be_socket_noop.so 14.20 -module libc_support_misc.so 14.21 -module libdl.so 14.22 -module libipc.so 14.23 -module libl4sys-direct.so 14.24 -module libl4sys.so 14.25 -module libl4util.so 14.26 -module libld-l4.so 14.27 -module libpthread.so 14.28 -module libstdc++.so 14.29 -module libsupc++.so 14.30 -module libuc_c.so
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/conf/dstest_file_client.cfg Thu Sep 01 21:52:41 2022 +0200 15.3 @@ -0,0 +1,40 @@ 15.4 +-- vim:set ft=lua: 15.5 + 15.6 +local L4 = require("L4"); 15.7 + 15.8 +local l = L4.default_loader; 15.9 + 15.10 +local blocksvr = l:new_channel(); 15.11 + 15.12 +l:startv({ 15.13 + caps = { 15.14 + server = blocksvr:svr(), 15.15 + }, 15.16 + log = { "blocksvr", "r" }, 15.17 + }, 15.18 + "rom/block_server", "10"); 15.19 + 15.20 +local ext2svr = l:new_channel(); 15.21 + 15.22 +l:startv({ 15.23 + caps = { 15.24 + blocksvr = blocksvr, 15.25 + ext2svr = ext2svr:svr(), 15.26 + }, 15.27 + log = { "ext2svr", "y" }, 15.28 + }, 15.29 + "rom/ext2_server", "blocksvr", "rom/e2test.fs", "10", "ext2svr"); 15.30 + 15.31 +-- Obtain user filesystems with umask 0022 (18). 15.32 + 15.33 +local open_for_user = 6; 15.34 +local ext2svr_paulb = L4.cast(L4.Proto.Factory, ext2svr):create(open_for_user, 1000, 1000, 18); 15.35 + 15.36 +l:startv({ 15.37 + caps = { 15.38 + server = ext2svr_paulb, 15.39 + }, 15.40 + log = { "client", "g" }, 15.41 + }, 15.42 + -- program, file to create 15.43 + "rom/dstest_file_client", "home/paulb/new file");
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/conf/dstest_file_client.list Thu Sep 01 21:52:41 2022 +0200 16.3 @@ -0,0 +1,27 @@ 16.4 +entry dstest_file_client 16.5 +roottask moe rom/dstest_file_client.cfg 16.6 +module dstest_file_client.cfg 16.7 +module e2test.fs 16.8 +module l4re 16.9 +module ned 16.10 +module dstest_file_client 16.11 +module ext2_server 16.12 +module block_server 16.13 +module lib4re-c.so 16.14 +module lib4re-c-util.so 16.15 +module lib4re.so 16.16 +module lib4re-util.so 16.17 +module libc_be_l4refile.so 16.18 +module libc_be_l4re.so 16.19 +module libc_be_socket_noop.so 16.20 +module libc_support_misc.so 16.21 +module libdl.so 16.22 +module libipc.so 16.23 +module libl4sys-direct.so 16.24 +module libl4sys.so 16.25 +module libl4util.so 16.26 +module libld-l4.so 16.27 +module libpthread.so 16.28 +module libstdc++.so 16.29 +module libsupc++.so 16.30 +module libuc_c.so
17.1 --- a/conf/dstest_file_readdir.cfg Thu Sep 01 21:40:39 2022 +0200 17.2 +++ b/conf/dstest_file_readdir.cfg Thu Sep 01 21:52:41 2022 +0200 17.3 @@ -47,5 +47,5 @@ 17.4 }, 17.5 log = { "client", "g" }, 17.6 }, 17.7 - -- program, directory to read 17.8 - "rom/dstest_file_readdir", "home/paulb/many"); 17.9 + -- program, directory to read, count of entries (files plus special entries) 17.10 + "rom/dstest_file_readdir", "home/paulb/many", "402");
18.1 --- a/conf/dstest_host.cfg Thu Sep 01 21:40:39 2022 +0200 18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 18.3 @@ -1,23 +0,0 @@ 18.4 --- vim:set ft=lua: 18.5 - 18.6 -local L4 = require("L4"); 18.7 - 18.8 -local l = L4.default_loader; 18.9 - 18.10 -local server = l:new_channel(); 18.11 - 18.12 -l:startv({ 18.13 - caps = { 18.14 - server = server:svr(), 18.15 - }, 18.16 - log = { "server", "r" }, 18.17 - }, 18.18 - "rom/host_server", "10"); 18.19 - 18.20 -l:startv({ 18.21 - caps = { 18.22 - server = server, 18.23 - }, 18.24 - log = { "client", "g" }, 18.25 - }, 18.26 - "rom/dstest_host_client", "rom/dstest_host.cfg", 1024, 1024);
19.1 --- a/conf/dstest_host.list Thu Sep 01 21:40:39 2022 +0200 19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 19.3 @@ -1,25 +0,0 @@ 19.4 -entry dstest_host 19.5 -roottask moe rom/dstest_host.cfg 19.6 -module dstest_host.cfg 19.7 -module l4re 19.8 -module ned 19.9 -module dstest_host_client 19.10 -module host_server 19.11 -module lib4re-c.so 19.12 -module lib4re-c-util.so 19.13 -module lib4re.so 19.14 -module lib4re-util.so 19.15 -module libc_be_l4refile.so 19.16 -module libc_be_l4re.so 19.17 -module libc_be_socket_noop.so 19.18 -module libc_support_misc.so 19.19 -module libdl.so 19.20 -module libipc.so 19.21 -module libl4sys-direct.so 19.22 -module libl4sys.so 19.23 -module libl4util.so 19.24 -module libld-l4.so 19.25 -module libpthread.so 19.26 -module libstdc++.so 19.27 -module libsupc++.so 19.28 -module libuc_c.so
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/conf/dstest_host_client.cfg Thu Sep 01 21:52:41 2022 +0200 20.3 @@ -0,0 +1,23 @@ 20.4 +-- vim:set ft=lua: 20.5 + 20.6 +local L4 = require("L4"); 20.7 + 20.8 +local l = L4.default_loader; 20.9 + 20.10 +local server = l:new_channel(); 20.11 + 20.12 +l:startv({ 20.13 + caps = { 20.14 + server = server:svr(), 20.15 + }, 20.16 + log = { "server", "r" }, 20.17 + }, 20.18 + "rom/host_server", "10"); 20.19 + 20.20 +l:startv({ 20.21 + caps = { 20.22 + server = server, 20.23 + }, 20.24 + log = { "client", "g" }, 20.25 + }, 20.26 + "rom/dstest_host_client", "rom/dstest_host_client.cfg", 1024, 1024);
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/conf/dstest_host_client.list Thu Sep 01 21:52:41 2022 +0200 21.3 @@ -0,0 +1,25 @@ 21.4 +entry dstest_host_client 21.5 +roottask moe rom/dstest_host_client.cfg 21.6 +module dstest_host_client.cfg 21.7 +module l4re 21.8 +module ned 21.9 +module dstest_host_client 21.10 +module host_server 21.11 +module lib4re-c.so 21.12 +module lib4re-c-util.so 21.13 +module lib4re.so 21.14 +module lib4re-util.so 21.15 +module libc_be_l4refile.so 21.16 +module libc_be_l4re.so 21.17 +module libc_be_socket_noop.so 21.18 +module libc_support_misc.so 21.19 +module libdl.so 21.20 +module libipc.so 21.21 +module libl4sys-direct.so 21.22 +module libl4sys.so 21.23 +module libl4util.so 21.24 +module libld-l4.so 21.25 +module libpthread.so 21.26 +module libstdc++.so 21.27 +module libsupc++.so 21.28 +module libuc_c.so
22.1 --- a/conf/dstest_host_readdir.cfg Thu Sep 01 21:40:39 2022 +0200 22.2 +++ b/conf/dstest_host_readdir.cfg Thu Sep 01 21:52:41 2022 +0200 22.3 @@ -31,4 +31,4 @@ 22.4 }, 22.5 log = { "client", "g" }, 22.6 }, 22.7 - "rom/dstest_file_readdir", "rom"); 22.8 + "rom/dstest_file_readdir", "rom", "23");
23.1 --- a/conf/dstest_pipe.cfg Thu Sep 01 21:40:39 2022 +0200 23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 23.3 @@ -1,23 +0,0 @@ 23.4 --- vim:set ft=lua: 23.5 - 23.6 -local L4 = require("L4"); 23.7 - 23.8 -local l = L4.default_loader; 23.9 - 23.10 -local server = l:new_channel(); 23.11 - 23.12 -l:startv({ 23.13 - caps = { 23.14 - server = server:svr(), 23.15 - }, 23.16 - log = { "server", "r" }, 23.17 - }, 23.18 - "rom/pipe_server", "10"); 23.19 - 23.20 -l:start({ 23.21 - caps = { 23.22 - pipes = server, 23.23 - }, 23.24 - log = { "client", "g" }, 23.25 - }, 23.26 - "rom/dstest_pipe_client");
24.1 --- a/conf/dstest_pipe.list Thu Sep 01 21:40:39 2022 +0200 24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 24.3 @@ -1,25 +0,0 @@ 24.4 -entry dstest_pipe 24.5 -roottask moe rom/dstest_pipe.cfg 24.6 -module dstest_pipe.cfg 24.7 -module l4re 24.8 -module ned 24.9 -module dstest_pipe_client 24.10 -module pipe_server 24.11 -module lib4re-c.so 24.12 -module lib4re-c-util.so 24.13 -module lib4re.so 24.14 -module lib4re-util.so 24.15 -module libc_be_l4refile.so 24.16 -module libc_be_l4re.so 24.17 -module libc_be_socket_noop.so 24.18 -module libc_support_misc.so 24.19 -module libdl.so 24.20 -module libipc.so 24.21 -module libl4sys-direct.so 24.22 -module libl4sys.so 24.23 -module libl4util.so 24.24 -module libld-l4.so 24.25 -module libpthread.so 24.26 -module libstdc++.so 24.27 -module libsupc++.so 24.28 -module libuc_c.so
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/conf/dstest_pipe_client.cfg Thu Sep 01 21:52:41 2022 +0200 25.3 @@ -0,0 +1,23 @@ 25.4 +-- vim:set ft=lua: 25.5 + 25.6 +local L4 = require("L4"); 25.7 + 25.8 +local l = L4.default_loader; 25.9 + 25.10 +local server = l:new_channel(); 25.11 + 25.12 +l:startv({ 25.13 + caps = { 25.14 + server = server:svr(), 25.15 + }, 25.16 + log = { "server", "r" }, 25.17 + }, 25.18 + "rom/pipe_server", "10"); 25.19 + 25.20 +l:start({ 25.21 + caps = { 25.22 + pipes = server, 25.23 + }, 25.24 + log = { "client", "g" }, 25.25 + }, 25.26 + "rom/dstest_pipe_client");
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/conf/dstest_pipe_client.list Thu Sep 01 21:52:41 2022 +0200 26.3 @@ -0,0 +1,25 @@ 26.4 +entry dstest_pipe_client 26.5 +roottask moe rom/dstest_pipe_client.cfg 26.6 +module dstest_pipe_client.cfg 26.7 +module l4re 26.8 +module ned 26.9 +module dstest_pipe_client 26.10 +module pipe_server 26.11 +module lib4re-c.so 26.12 +module lib4re-c-util.so 26.13 +module lib4re.so 26.14 +module lib4re-util.so 26.15 +module libc_be_l4refile.so 26.16 +module libc_be_l4re.so 26.17 +module libc_be_socket_noop.so 26.18 +module libc_support_misc.so 26.19 +module libdl.so 26.20 +module libipc.so 26.21 +module libl4sys-direct.so 26.22 +module libl4sys.so 26.23 +module libl4util.so 26.24 +module libld-l4.so 26.25 +module libpthread.so 26.26 +module libstdc++.so 26.27 +module libsupc++.so 26.28 +module libuc_c.so
27.1 --- a/conf/dstest_test.cfg Thu Sep 01 21:40:39 2022 +0200 27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 27.3 @@ -1,31 +0,0 @@ 27.4 --- vim:set ft=lua: 27.5 - 27.6 -local L4 = require("L4"); 27.7 - 27.8 -local l = L4.default_loader; 27.9 - 27.10 -local server = l:new_channel(); 27.11 - 27.12 -l:startv({ 27.13 - caps = { 27.14 - server = server:svr(), 27.15 - }, 27.16 - log = { "server", "r" }, 27.17 - }, 27.18 - "rom/test_server", "40"); 27.19 - 27.20 -l:start({ 27.21 - caps = { 27.22 - server = server, 27.23 - }, 27.24 - log = { "client1", "g" }, 27.25 - }, 27.26 - "rom/dstest_test_client"); 27.27 - 27.28 -l:start({ 27.29 - caps = { 27.30 - server = server, 27.31 - }, 27.32 - log = { "client2", "b" }, 27.33 - }, 27.34 - "rom/dstest_test_client");
28.1 --- a/conf/dstest_test.list Thu Sep 01 21:40:39 2022 +0200 28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 28.3 @@ -1,25 +0,0 @@ 28.4 -entry dstest_test 28.5 -roottask moe rom/dstest_test.cfg 28.6 -module dstest_test.cfg 28.7 -module l4re 28.8 -module ned 28.9 -module dstest_test_client 28.10 -module test_server 28.11 -module lib4re-c.so 28.12 -module lib4re-c-util.so 28.13 -module lib4re.so 28.14 -module lib4re-util.so 28.15 -module libc_be_l4refile.so 28.16 -module libc_be_l4re.so 28.17 -module libc_be_socket_noop.so 28.18 -module libc_support_misc.so 28.19 -module libdl.so 28.20 -module libipc.so 28.21 -module libl4sys-direct.so 28.22 -module libl4sys.so 28.23 -module libl4util.so 28.24 -module libld-l4.so 28.25 -module libpthread.so 28.26 -module libstdc++.so 28.27 -module libsupc++.so 28.28 -module libuc_c.so
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/conf/dstest_test_client.cfg Thu Sep 01 21:52:41 2022 +0200 29.3 @@ -0,0 +1,31 @@ 29.4 +-- vim:set ft=lua: 29.5 + 29.6 +local L4 = require("L4"); 29.7 + 29.8 +local l = L4.default_loader; 29.9 + 29.10 +local server = l:new_channel(); 29.11 + 29.12 +l:startv({ 29.13 + caps = { 29.14 + server = server:svr(), 29.15 + }, 29.16 + log = { "server", "r" }, 29.17 + }, 29.18 + "rom/test_server", "40"); 29.19 + 29.20 +l:start({ 29.21 + caps = { 29.22 + server = server, 29.23 + }, 29.24 + log = { "client1", "g" }, 29.25 + }, 29.26 + "rom/dstest_test_client"); 29.27 + 29.28 +l:start({ 29.29 + caps = { 29.30 + server = server, 29.31 + }, 29.32 + log = { "client2", "b" }, 29.33 + }, 29.34 + "rom/dstest_test_client");
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/conf/dstest_test_client.list Thu Sep 01 21:52:41 2022 +0200 30.3 @@ -0,0 +1,25 @@ 30.4 +entry dstest_test_client 30.5 +roottask moe rom/dstest_test_client.cfg 30.6 +module dstest_test_client.cfg 30.7 +module l4re 30.8 +module ned 30.9 +module dstest_test_client 30.10 +module test_server 30.11 +module lib4re-c.so 30.12 +module lib4re-c-util.so 30.13 +module lib4re.so 30.14 +module lib4re-util.so 30.15 +module libc_be_l4refile.so 30.16 +module libc_be_l4re.so 30.17 +module libc_be_socket_noop.so 30.18 +module libc_support_misc.so 30.19 +module libdl.so 30.20 +module libipc.so 30.21 +module libl4sys-direct.so 30.22 +module libl4sys.so 30.23 +module libl4util.so 30.24 +module libld-l4.so 30.25 +module libpthread.so 30.26 +module libstdc++.so 30.27 +module libsupc++.so 30.28 +module libuc_c.so
31.1 --- a/docs/wiki/Client_Library Thu Sep 01 21:40:39 2022 +0200 31.2 +++ b/docs/wiki/Client_Library Thu Sep 01 21:52:41 2022 +0200 31.3 @@ -9,13 +9,21 @@ 31.4 31.5 <<TableOfContents(2,3)>> 31.6 31.7 +== Header Files == 31.8 + 31.9 +The following header files are pertinent to client library usage: 31.10 + 31.11 +|| '''File''' || '''Description''' || 31.12 +|| `fsclient/client.h` || Client functions and data structures || 31.13 +|| `systypes/fcntl.h` || Flag values for opening operations || 31.14 + 31.15 == File Data Structures == 31.16 31.17 Since files are accessed using file references, the `file_t` data structure is 31.18 used to wrap such references and other relevant state. Thus, such structures 31.19 can be broadly regarded as similar to the traditional `FILE` data structure. 31.20 31.21 -The fields of the `file_t` data structure are as follows: 31.22 +The members of the `file_t` data structure are as follows: 31.23 31.24 || '''Field''' || '''Description''' || 31.25 || `ref` || A reference to the component providing file content || 31.26 @@ -29,6 +37,10 @@ 31.27 || `can_block` || Notification flags for blocking access to the file || 31.28 || `notifications`|| Notification flags set for the file || 31.29 || `flags` || The flags used to open the file || 31.30 +|| `error` || Any failure or error condition on the file || 31.31 + 31.32 +Generally, these members should not be accessed directly, mostly being 31.33 +reserved for use by the client library itself. 31.34 31.35 == Client Programming Interface == 31.36 31.37 @@ -38,23 +50,63 @@ 31.38 31.39 === Files === 31.40 31.41 -Files are opened and closed using the following functions: 31.42 +Files are opened using the following function returning a file data structure: 31.43 31.44 {{{ 31.45 file_t *client_open(const char *name, flags_t flags); 31.46 }}} 31.47 31.48 -Each file endpoint may be closed using `client_close`. 31.49 +To test whether the file was successfully open, the following function should 31.50 +be invoked, this returning a true (non-zero) value if the file was 31.51 +successfully opened: 31.52 + 31.53 +{{{ 31.54 +int client_opened(file_t *file); 31.55 +}}} 31.56 + 31.57 +Each file should be closed using `client_close` regardless of whether the file 31.58 +was successfully opened. 31.59 + 31.60 +==== Example ==== 31.61 + 31.62 +{{{ 31.63 +file_t *file = client_open("somefile", O_RDONLY); 31.64 + 31.65 +if (client_opened(file)) 31.66 +{ 31.67 + /* Perform operations on file. */ 31.68 +} 31.69 + 31.70 +client_close(file); 31.71 +}}} 31.72 31.73 === Pipes === 31.74 31.75 -Pipes are opened using a special function: 31.76 +Pipes are opened using a special function returning an error code, setting the 31.77 +supplied reader and writer endpoint parameters: 31.78 31.79 {{{ 31.80 long client_pipe(file_t **reader, file_t **writer, flags_t flags); 31.81 }}} 31.82 31.83 -Each pipe endpoint may be closed using `client_close`. 31.84 +Each returned pipe endpoint may be closed using `client_close`. If an error 31.85 +condition is reported using a non-zero value, the endpoints will not be 31.86 +retained and will therefore not need to be closed: the error condition is 31.87 +communicated purely via the return value. 31.88 + 31.89 +==== Example ==== 31.90 + 31.91 +{{{ 31.92 +file_t *reader, *writer; 31.93 + 31.94 +if (!client_pipe(&reader, &writer, 0)) 31.95 +{ 31.96 + /* Perform operations on pipe. */ 31.97 +} 31.98 + 31.99 +client_close(reader); 31.100 +client_close(writer); 31.101 +}}} 31.102 31.103 === Closing Files and Pipes === 31.104 31.105 @@ -94,9 +146,33 @@ 31.106 memory, a function can be used to explicitly reference memory for file access: 31.107 31.108 {{{ 31.109 -void *client_mmap(file_t *file, offset_t position, offset_t length); 31.110 +void *client_mmap(file_t *file, offset_t position, offset_t length, 31.111 + offset_t start_visible, offset_t end_visible, 31.112 + l4re_rm_flags_t region_flags); 31.113 }}} 31.114 31.115 +Here, a portion of the indicated `file` is exposed in a memory region, with 31.116 +the memory region corresponding to the contents of the file starting at the 31.117 +given `position` in the file and having a span of the given `length` in bytes. 31.118 + 31.119 +Additional parameters control masking of the file content. If `start_visible` 31.120 +and `end_visible` are both non-zero, then they indicate a visible span in the 31.121 +file. Such limits are applied to the mapped region, with locations 31.122 +corresponding to positions before `start_visible` and positions after 31.123 +`end_visible` yielding zero byte values. 31.124 + 31.125 +The `region_flags` indicate the memory access properties of the mapped region 31.126 +in the task obtaining it. For example, where a region will be populated with 31.127 +code, the `L4RE_DS_F_RX` flag would be appropriate, this indicating that the 31.128 +region will be read and also have its contents run or executed. 31.129 + 31.130 +'''Note:''' Currently, when masking is applied to a file, any write operations 31.131 +will cause the modified memory to be copied and modified, as opposed to 31.132 +causing modifications to the underlying file content. This behaviour may 31.133 +eventually be more configurable. 31.134 + 31.135 +=== Accessing Pipe Content in Memory Regions === 31.136 + 31.137 Pipes support a different mechanism for navigation involving the following 31.138 functions: 31.139
32.1 --- a/libfsclient/include/fsclient/client.h Thu Sep 01 21:40:39 2022 +0200 32.2 +++ b/libfsclient/include/fsclient/client.h Thu Sep 01 21:52:41 2022 +0200 32.3 @@ -47,6 +47,10 @@ 32.4 long client_pipe(file_t **reader, file_t **writer, flags_t flags); 32.5 long client_pipe_using(file_t **reader, file_t **writer, flags_t flags, l4_cap_idx_t server); 32.6 32.7 +/* File status testing. */ 32.8 + 32.9 +int client_opened(file_t *file); 32.10 + 32.11 /* Other file operations. */ 32.12 32.13 long client_mkdir(const char *path, mode_t mode);
33.1 --- a/libfsclient/include/fsclient/file.h Thu Sep 01 21:40:39 2022 +0200 33.2 +++ b/libfsclient/include/fsclient/file.h Thu Sep 01 21:52:41 2022 +0200 33.3 @@ -79,6 +79,10 @@ 33.4 33.5 flags_t flags; 33.6 33.7 + /* Any failure or error condition on the file. */ 33.8 + 33.9 + long error; 33.10 + 33.11 } file_t; 33.12 33.13
34.1 --- a/libfsclient/lib/src/client.cc Thu Sep 01 21:40:39 2022 +0200 34.2 +++ b/libfsclient/lib/src/client.cc Thu Sep 01 21:52:41 2022 +0200 34.3 @@ -135,7 +135,9 @@ 34.4 /* Within the current pipe region, synchronise with the pipe object. */ 34.5 34.6 else 34.7 + { 34.8 return client_current_region(file); 34.9 + } 34.10 } 34.11 } 34.12 34.13 @@ -148,8 +150,8 @@ 34.14 static int _operation_blocking(file_t *file, int reading) 34.15 { 34.16 return (file->can_block && !(file->notifications & NOTIFY_PEER_CLOSED) && ( 34.17 - (reading && !file_data_available(file)) || 34.18 - (!reading && !file_data_space(file)))); 34.19 + (reading && !file_data_available(file)) || 34.20 + (!reading && !file_data_space(file)))); 34.21 } 34.22 34.23 34.24 @@ -264,12 +266,9 @@ 34.25 if (file == NULL) 34.26 return NULL; 34.27 34.28 - if (file_open(file, name, flags, server)) 34.29 - { 34.30 - free(file); 34.31 - return NULL; 34.32 - } 34.33 + /* Return any allocated structure even if an error occurs. */ 34.34 34.35 + file->error = file_open(file, name, flags, server); 34.36 return file; 34.37 } 34.38 34.39 @@ -296,10 +295,7 @@ 34.40 34.41 file_t *reader = client_opendir_at(file); 34.42 34.43 - if (reader == NULL) 34.44 - return NULL; 34.45 - 34.46 - /* Release the directory and return the reader. */ 34.47 + /* Release the directory and return the reader even if an error occurs. */ 34.48 34.49 client_close(file); 34.50 return reader; 34.51 @@ -311,7 +307,7 @@ 34.52 34.53 file_t *client_opendir_at(file_t *file) 34.54 { 34.55 - if (file == NULL) 34.56 + if (!client_opened(file)) 34.57 return NULL; 34.58 34.59 file_t *reader = (file_t *) malloc(sizeof(file_t)); 34.60 @@ -319,26 +315,23 @@ 34.61 if (reader == NULL) 34.62 return NULL; 34.63 34.64 - long err = directory_opendir(file, reader); 34.65 + /* Return any allocated structure even if an error occurs. */ 34.66 34.67 - if (err) 34.68 - return NULL; 34.69 + reader->error = directory_opendir(file, reader); 34.70 34.71 /* Set blocking read mode to be able to conveniently read directory entries 34.72 - from the stream. */ 34.73 + from the stream. If this fails, the error is set on the structure, but the 34.74 + stream will be open. */ 34.75 34.76 - if (client_set_blocking(reader, NOTIFY_CONTENT_AVAILABLE | NOTIFY_PEER_CLOSED)) 34.77 - { 34.78 - client_close(reader); 34.79 - return NULL; 34.80 - } 34.81 + if (!reader->error) 34.82 + reader->error = client_set_blocking(reader, NOTIFY_CONTENT_AVAILABLE | NOTIFY_PEER_CLOSED); 34.83 34.84 return reader; 34.85 } 34.86 34.87 34.88 34.89 -/* Open a pipe object. */ 34.90 +/* Open a pipe object, returning any error condition. */ 34.91 34.92 long client_pipe(file_t **reader, file_t **writer, flags_t flags) 34.93 { 34.94 @@ -349,6 +342,9 @@ 34.95 34.96 long client_pipe_using(file_t **reader, file_t **writer, flags_t flags, l4_cap_idx_t server) 34.97 { 34.98 + *reader = NULL; 34.99 + *writer = NULL; 34.100 + 34.101 if (l4_is_invalid_cap(server)) 34.102 return -L4_EINVAL; 34.103 34.104 @@ -387,6 +383,15 @@ 34.105 34.106 34.107 34.108 +/* Determine whether a file has been successfully opened. */ 34.109 + 34.110 +int client_opened(file_t *file) 34.111 +{ 34.112 + return (file != NULL) && !file->error; 34.113 +} 34.114 + 34.115 + 34.116 + 34.117 /* Make a directory in the filesystem. */ 34.118 34.119 long client_mkdir(const char *path, mode_t mode) 34.120 @@ -463,7 +468,7 @@ 34.121 34.122 long client_current_region(file_t *file) 34.123 { 34.124 - if (file == NULL) 34.125 + if (!client_opened(file)) 34.126 return -L4_EINVAL; 34.127 34.128 return pipe_current(file); 34.129 @@ -475,7 +480,7 @@ 34.130 34.131 long client_flush(file_t *file) 34.132 { 34.133 - if (file == NULL) 34.134 + if (!client_opened(file)) 34.135 return -L4_EINVAL; 34.136 34.137 /* Flush and retain most buffer settings. */ 34.138 @@ -491,8 +496,8 @@ 34.139 offset_t start_visible, offset_t end_visible, 34.140 l4re_rm_flags_t region_flags) 34.141 { 34.142 - if ((file == NULL) || file_mmap(file, position, length, start_visible, 34.143 - end_visible, region_flags)) 34.144 + if (!client_opened(file) || file_mmap(file, position, length, start_visible, 34.145 + end_visible, region_flags)) 34.146 return NULL; 34.147 34.148 return file->memory; 34.149 @@ -504,7 +509,7 @@ 34.150 34.151 long client_next_region(file_t *file) 34.152 { 34.153 - if (file == NULL) 34.154 + if (!client_opened(file)) 34.155 return -L4_EINVAL; 34.156 34.157 return pipe_next(file); 34.158 @@ -584,7 +589,7 @@ 34.159 34.160 offset_t client_read(file_t *file, void *buf, offset_t count) 34.161 { 34.162 - if (file == NULL) 34.163 + if (!client_opened(file)) 34.164 return 0; 34.165 34.166 /* Map memory if none has been mapped so far. */ 34.167 @@ -640,7 +645,7 @@ 34.168 34.169 offset_t client_seek(file_t *file, offset_t offset, int whence) 34.170 { 34.171 - if (file == NULL) 34.172 + if (!client_opened(file)) 34.173 return 0; 34.174 34.175 offset_t position, current = file_data_current_position(file), change; 34.176 @@ -743,7 +748,7 @@ 34.177 34.178 long client_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier) 34.179 { 34.180 - if (file == NULL) 34.181 + if (!client_opened(file)) 34.182 return -L4_EINVAL; 34.183 34.184 return file_notify_subscribe(file, flags, notifier); 34.185 @@ -755,7 +760,7 @@ 34.186 34.187 long client_tell(file_t *file) 34.188 { 34.189 - if (file == NULL) 34.190 + if (!client_opened(file)) 34.191 return -L4_EINVAL; 34.192 34.193 return file_data_current_position(file); 34.194 @@ -767,7 +772,7 @@ 34.195 34.196 long client_unsubscribe(file_t *file, file_notifier_t *notifier) 34.197 { 34.198 - if (file == NULL) 34.199 + if (!client_opened(file)) 34.200 return -L4_EINVAL; 34.201 34.202 return file_notify_unsubscribe(file, notifier); 34.203 @@ -779,7 +784,7 @@ 34.204 34.205 long client_wait_file(file_t *file, file_notifier_t *notifier) 34.206 { 34.207 - if (file == NULL) 34.208 + if (!client_opened(file)) 34.209 return -L4_EINVAL; 34.210 34.211 return file_notify_wait_file(file, notifier); 34.212 @@ -799,7 +804,7 @@ 34.213 34.214 offset_t client_write(file_t *file, const void *buf, offset_t count) 34.215 { 34.216 - if (file == NULL) 34.217 + if (!client_opened(file)) 34.218 return 0; 34.219 34.220 /* Map memory if none has been mapped so far. */
35.1 --- a/libfsclient/lib/src/file.cc Thu Sep 01 21:40:39 2022 +0200 35.2 +++ b/libfsclient/lib/src/file.cc Thu Sep 01 21:52:41 2022 +0200 35.3 @@ -91,6 +91,7 @@ 35.4 file->can_block = 0; 35.5 file->notifications = 0; 35.6 file->flags = 0; 35.7 + file->error = 0; 35.8 } 35.9 35.10
36.1 --- a/libfsserver/lib/generic/pager.cc Thu Sep 01 21:40:39 2022 +0200 36.2 +++ b/libfsserver/lib/generic/pager.cc Thu Sep 01 21:52:41 2022 +0200 36.3 @@ -66,7 +66,8 @@ 36.4 return L4_EOK; 36.5 } 36.6 36.7 -/* Resize the underlying file. */ 36.8 +/* Resize the file. This will only resize the underlying file where masking and 36.9 + copy-on-write mapping is not being performed. */ 36.10 36.11 long Pager::resize(offset_t *size) 36.12 { 36.13 @@ -87,7 +88,7 @@ 36.14 _start = trunc(position, PAGE_SIZE); 36.15 _size = round(position + length, PAGE_SIZE) - _start; 36.16 36.17 - /* Return the start and end positions plus populated extent. */ 36.18 + /* Return the start and end positions plus file size. */ 36.19 36.20 *start_pos = _start; 36.21 *end_pos = _start + _size;
37.1 --- a/test_files/mk_e2test.sh Thu Sep 01 21:40:39 2022 +0200 37.2 +++ b/test_files/mk_e2test.sh Thu Sep 01 21:52:41 2022 +0200 37.3 @@ -55,6 +55,11 @@ 37.4 37.5 OPTIONS='-u 1000 -g 1000' 37.6 37.7 +# Test parameters. 37.8 +# See: tests/dstest_file_readdir.cfg 37.9 + 37.10 +MANY_FILES_COUNT=400 37.11 + 37.12 # Define a convenience function for e2access invocation. 37.13 37.14 e2access() 37.15 @@ -99,7 +104,7 @@ 37.16 37.17 # Populate the directory with plenty of files. 37.18 37.19 -for N in `seq 1 400`; do 37.20 +for N in `seq 1 $MANY_FILES_COUNT`; do 37.21 echo "Contents of #$N." > "file-$N".txt 37.22 done 37.23
38.1 --- a/tests/dstest_block_client.cc Thu Sep 01 21:40:39 2022 +0200 38.2 +++ b/tests/dstest_block_client.cc Thu Sep 01 21:52:41 2022 +0200 38.3 @@ -33,36 +33,47 @@ 38.4 38.5 38.6 38.7 -static void show(file_t *file, unsigned long step, unsigned long sample) 38.8 +static void show(file_t *file, offset_t step, offset_t sample) 38.9 { 38.10 /* Allocate a buffer for sampling from the file. */ 38.11 38.12 char buf[sample + 1]; 38.13 38.14 - for (unsigned long offset = 0; offset < file_populated_span(file); offset += step) 38.15 + for (offset_t offset = 0; offset < file_populated_span(file); offset += step) 38.16 { 38.17 - unsigned long remaining = file_populated_span(file) - offset; 38.18 - unsigned long sample_remaining = remaining < sample ? remaining : sample; 38.19 + offset_t remaining = file_populated_span(file) - offset; 38.20 + offset_t sample_remaining = remaining < sample ? remaining : sample; 38.21 38.22 printf("%ld bytes from %p...\n", sample_remaining, (file->memory + offset)); 38.23 memcpy(buf, (file->memory + offset), sample_remaining); 38.24 buf[sample_remaining] = '\0'; 38.25 38.26 - unsigned long leading = 0; 38.27 + offset_t leading = 0; 38.28 char *outbuf = buf; 38.29 38.30 + /* Skip leading zero bytes. */ 38.31 + 38.32 while ((*outbuf == '\0') && (leading < sample_remaining)) 38.33 { 38.34 outbuf++; 38.35 leading++; 38.36 } 38.37 38.38 - if (leading) 38.39 - printf("[%ld zero bytes]\n", leading); 38.40 + offset_t trailing = 0; 38.41 + char *outbuf_end = outbuf + strlen(outbuf), *end = buf + sample_remaining - 1; 38.42 38.43 - printf("%s\n", outbuf); 38.44 + while ((*end == '\0') && (end >= outbuf_end)) 38.45 + { 38.46 + end--; 38.47 + trailing++; 38.48 + } 38.49 38.50 + printf("----\n%s\n----\n", outbuf); 38.51 + 38.52 + printf("[%ld zero bytes at start]\n", leading); 38.53 + printf("[%ld bytes shown]\n", strlen(outbuf)); 38.54 printf("[%ld bytes after string]\n", sample_remaining - leading - strlen(outbuf)); 38.55 + printf("[%ld zero bytes at end]\n", trailing); 38.56 } 38.57 } 38.58 38.59 @@ -77,8 +88,8 @@ 38.60 /* Obtain filename and access parameters. */ 38.61 38.62 char *filename = argv[1]; 38.63 - unsigned long step = atoi(argv[2]); 38.64 - unsigned long sample = atoi(argv[3]); 38.65 + offset_t step = atoi(argv[2]); 38.66 + offset_t sample = atoi(argv[3]); 38.67 38.68 /* Obtain access to the filesystem. */ 38.69 38.70 @@ -95,10 +106,13 @@ 38.71 return 1; 38.72 } 38.73 38.74 - /* A region of the file is mapped. Here, the start and length will not provide 38.75 - page-aligned offsets, but the region is nevertheless not masked. */ 38.76 + offset_t original_size = file.size; 38.77 38.78 - err = file_mmap(&file, 10, 290, 0, 0, file_region_flags(file.flags)); 38.79 + /* A region of the file is mapped. Here, the start and length is not provided 38.80 + as page-aligned offsets, but the region is nevertheless not masked, and the 38.81 + region limits will be page-aligned in any case. */ 38.82 + 38.83 + err = file_mmap(&file, 10, original_size - 20, 0, 0, file_region_flags(file.flags)); 38.84 38.85 if (err) 38.86 { 38.87 @@ -106,16 +120,23 @@ 38.88 return 1; 38.89 } 38.90 38.91 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.92 printf("File contents:\n"); 38.93 38.94 show(&file, step, sample); 38.95 38.96 printf("File shown.\n"); 38.97 + printf("Expected...\n" 38.98 + "[0 zero bytes at start]\n" 38.99 + "[%ld bytes shown]\n" 38.100 + "[0 bytes after string]\n" 38.101 + "[0 zero bytes at end]\n\n", 38.102 + original_size); 38.103 38.104 /* A region of the file is mapped. Here, the resulting offsets will be used to 38.105 define a masked region. */ 38.106 38.107 - err = file_mmap(&file, 10, 290, 10, 290, file_region_flags(file.flags)); 38.108 + err = file_mmap(&file, 10, original_size - 20, 10, original_size - 10, file_region_flags(file.flags)); 38.109 38.110 if (err) 38.111 { 38.112 @@ -123,18 +144,27 @@ 38.113 return 1; 38.114 } 38.115 38.116 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.117 printf("File contents:\n"); 38.118 38.119 show(&file, step, sample); 38.120 38.121 printf("File shown.\n"); 38.122 + printf("Expected...\n" 38.123 + "[10 zero bytes at start]\n" 38.124 + "[%ld bytes shown]\n" 38.125 + "[%ld bytes after string]\n" 38.126 + "[%ld zero bytes at end]\n\n", 38.127 + original_size - 20, 10UL, 10UL); 38.128 38.129 /* Resizing must occur before writing beyond the end of file. Otherwise, the 38.130 data may get discarded if the supporting flexpage needs to be flushed. */ 38.131 38.132 - offset_t old_size = file_populated_span(&file); 38.133 - offset_t new_region = round(old_size, page(1)); 38.134 - offset_t new_size = new_region + old_size; 38.135 + offset_t old_populated_size = file_populated_span(&file); 38.136 + offset_t old_size = file.size; 38.137 + offset_t old_populated_size_rounded = round(old_populated_size, page(1)); 38.138 + offset_t new_size = old_populated_size_rounded + old_populated_size; 38.139 + offset_t new_region = round(new_size, page(1)); 38.140 38.141 printf("Resize to %ld...\n", new_size); 38.142 38.143 @@ -147,10 +177,12 @@ 38.144 } 38.145 38.146 printf("Resized file...\n"); 38.147 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.148 + printf("Expected %ld...%ld populated size %ld size %ld.\n\n", 0UL, old_populated_size_rounded, old_populated_size_rounded, new_size); 38.149 38.150 /* Re-map to avoid masking the region. */ 38.151 38.152 - err = file_mmap(&file, 10, new_size - 20, 0, 0, file_region_flags(file.flags)); 38.153 + err = file_mmap(&file, 0, new_size, 0, 0, file_region_flags(file.flags)); 38.154 38.155 if (err) 38.156 { 38.157 @@ -158,27 +190,52 @@ 38.158 return 1; 38.159 } 38.160 38.161 - /* Copy the sampled data to another file region. */ 38.162 + printf("Remapped file without masking...\n"); 38.163 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.164 + printf("Expected %ld...%ld populated size %ld size %ld.\n\n", 0UL, new_region, old_populated_size, old_size); 38.165 38.166 - printf("Copy data to %ld...\n", new_region); 38.167 + printf("Resize to %ld...\n", new_size); 38.168 38.169 - for (unsigned long offset = 0; offset < old_size; offset += step) 38.170 + err = file_resize(&file, new_size); 38.171 + 38.172 + if (err) 38.173 { 38.174 - printf("Copying to %ld...\n", new_region + offset); 38.175 - memcpy(file.memory + new_region + offset, file.memory + offset, sample); 38.176 - if (step > sample) 38.177 - memset(file.memory + new_region + offset + sample, 0, step - sample); 38.178 + printf("Could not resize file: %s\n", l4sys_errtostr(err)); 38.179 + return 1; 38.180 } 38.181 38.182 + printf("Resized file...\n"); 38.183 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.184 + printf("Expected %ld...%ld populated size %ld size %ld.\n\n", 0UL, round(new_size, page(1)), new_size, new_size); 38.185 + 38.186 + /* Copy the file data to another file region. */ 38.187 + 38.188 + printf("Copy data to %ld...\n", old_populated_size_rounded); 38.189 + 38.190 + memcpy(file.memory + old_populated_size_rounded, file.memory, old_size); 38.191 + 38.192 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.193 printf("File contents:\n"); 38.194 38.195 show(&file, step, sample); 38.196 38.197 printf("File shown.\n"); 38.198 + printf("Expected...\n" 38.199 + "[0 zero bytes at start]\n" 38.200 + "[%ld bytes shown]\n" 38.201 + "[%ld bytes after string]\n" 38.202 + "[%ld zero bytes at end]\n" 38.203 + "...\n" 38.204 + "[0 zero bytes at start]\n" 38.205 + "[%ld bytes shown]\n" 38.206 + "[0 bytes after string]\n" 38.207 + "[0 zero bytes at end]\n\n", 38.208 + original_size, sample - original_size, sample - original_size, 38.209 + original_size); 38.210 38.211 /* Re-map to mask the region again. */ 38.212 38.213 - err = file_mmap(&file, 0, new_size, 10, new_size - 20, file_region_flags(file.flags)); 38.214 + err = file_mmap(&file, 0, new_size, 10, new_size - 10, file_region_flags(file.flags)); 38.215 38.216 if (err) 38.217 { 38.218 @@ -186,12 +243,26 @@ 38.219 return 1; 38.220 } 38.221 38.222 + printf("Region %ld...%ld populated size %ld size %ld.\n", file.start_pos, file.end_pos, file_populated_span(&file), file.size); 38.223 printf("File contents:\n"); 38.224 38.225 show(&file, step, sample); 38.226 38.227 printf("File shown.\n"); 38.228 + printf("Expected...\n" 38.229 + "[10 zero bytes at start]\n" 38.230 + "[%ld bytes shown]\n" 38.231 + "[%ld bytes after string]\n" 38.232 + "[%ld zero bytes at end]\n" 38.233 + "...\n" 38.234 + "[0 zero bytes at start]\n" 38.235 + "[%ld bytes shown]\n" 38.236 + "[10 bytes after string]\n" 38.237 + "[10 zero bytes at end]\n", 38.238 + original_size - 10, sample - original_size, sample - original_size, 38.239 + original_size - 10); 38.240 38.241 + printf("End of test.\n"); 38.242 return 0; 38.243 } 38.244
39.1 --- a/tests/dstest_block_client_simple.cc Thu Sep 01 21:40:39 2022 +0200 39.2 +++ b/tests/dstest_block_client_simple.cc Thu Sep 01 21:52:41 2022 +0200 39.3 @@ -45,8 +45,9 @@ 39.4 39.5 file = client_open(filename, O_RDWR); 39.6 39.7 - if (file == NULL) 39.8 + if (!client_opened(file)) 39.9 { 39.10 + client_close(file); 39.11 printf("Could not obtain file.\n"); 39.12 return 1; 39.13 } 39.14 @@ -54,6 +55,8 @@ 39.15 /* Copy the sampled data to another file region. */ 39.16 39.17 offset_t size = file->size; 39.18 + offset_t new_size = size * (repetition + 1); 39.19 + 39.20 char buffer[size]; 39.21 offset_t nread = client_read(file, buffer, size); 39.22 39.23 @@ -83,7 +86,8 @@ 39.24 } 39.25 } 39.26 39.27 - printf("File is now %ld in size.\n", file->size); 39.28 + printf("File now has size %ld.\n", file->size); 39.29 + printf("File has expected size %ld: %s\n", new_size, new_size == file->size ? "True" : "False"); 39.30 39.31 printf("Seek to start...\n"); 39.32 39.33 @@ -96,10 +100,8 @@ 39.34 39.35 offset_t position = 0; 39.36 39.37 - while (position < file->size) 39.38 + while ((nread = client_read(file, buffer, size)) > 0) 39.39 { 39.40 - offset_t nread = client_read(file, buffer, size); 39.41 - 39.42 if ((nread != size) && (nread != file->size - position)) 39.43 { 39.44 printf("Could not read file section: %ld instead of %ld or remaining %ld bytes.\n", 39.45 @@ -111,8 +113,8 @@ 39.46 position += nread; 39.47 } 39.48 39.49 - printf("File shown.\n"); 39.50 - 39.51 + printf("File shown in its entirety: %s\n", position == file->size ? "True" : "False"); 39.52 + printf("End of test.\n"); 39.53 return 0; 39.54 } 39.55
40.1 --- a/tests/dstest_exec.cc Thu Sep 01 21:40:39 2022 +0200 40.2 +++ b/tests/dstest_exec.cc Thu Sep 01 21:52:41 2022 +0200 40.3 @@ -316,7 +316,14 @@ 40.4 return 1; 40.5 } 40.6 40.7 - printf("Finished.\n"); 40.8 + printf("Finished program initiation.\n"); 40.9 + printf("End of test.\n"); 40.10 + 40.11 + /* NOTE: Should be able to obtain a notification for when the program 40.12 + finishes, which might be done using a capability deletion IRQ. 40.13 + Eventually, this program will operate as a server, invoking new 40.14 + programs and handling termination. This test would then merely 40.15 + involve the invocation of a utility function. */ 40.16 40.17 while (1) 40.18 l4_sleep_forever();
41.1 --- a/tests/dstest_ext2fs_client.cc Thu Sep 01 21:40:39 2022 +0200 41.2 +++ b/tests/dstest_ext2fs_client.cc Thu Sep 01 21:52:41 2022 +0200 41.3 @@ -1,7 +1,7 @@ 41.4 /* 41.5 - * Test dataspace operations. 41.6 + * Test libext2fs operations on L4Re-provided files. 41.7 * 41.8 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk> 41.9 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk> 41.10 * 41.11 * This program is free software; you can redistribute it and/or 41.12 * modify it under the terms of the GNU General Public License as 41.13 @@ -55,7 +55,7 @@ 41.14 } 41.15 41.16 printf("Access completed.\n"); 41.17 - 41.18 + printf("End of test.\n"); 41.19 return 0; 41.20 } 41.21
42.1 --- a/tests/dstest_file_access.cc Thu Sep 01 21:40:39 2022 +0200 42.2 +++ b/tests/dstest_file_access.cc Thu Sep 01 21:52:41 2022 +0200 42.3 @@ -47,13 +47,14 @@ 42.4 42.5 file_t *reader = client_opendir(dirname); 42.6 42.7 - if (reader == NULL) 42.8 + if (!client_opened(reader)) 42.9 { 42.10 + client_close(reader); 42.11 printf("Could not read from directory: %s\n", dirname); 42.12 continue; 42.13 } 42.14 42.15 - printf("Reading...\n"); 42.16 + printf(" Reading...\n"); 42.17 42.18 struct dirent *dirent; 42.19 42.20 @@ -67,31 +68,31 @@ 42.21 42.22 sprintf(path, "%s/%s", dirname, filename); 42.23 42.24 - printf("Attempt to read %s...\n", filename); 42.25 + printf(" Attempt to read %s...\n", filename); 42.26 42.27 file_t *file = client_open(path, O_RDONLY); 42.28 42.29 - if (file == NULL) 42.30 - printf("Could not open file: %s\n", filename); 42.31 + if (!client_opened(file)) 42.32 + printf(" Could not open file: %s\n", filename); 42.33 else 42.34 { 42.35 char buffer[32]; 42.36 offset_t nread = client_read(file, buffer, 32); 42.37 42.38 - fputs("Start of file: ", stdout); 42.39 + fputs(" Start of file:\n----\n", stdout); 42.40 fwrite(buffer, sizeof(char), nread, stdout); 42.41 - fputs("\n", stdout); 42.42 - 42.43 - client_close(file); 42.44 + fputs("\n----\n", stdout); 42.45 } 42.46 42.47 + client_close(file); 42.48 free(dirent); 42.49 } 42.50 42.51 - printf("Directory shown.\n"); 42.52 - 42.53 + client_close(reader); 42.54 + printf("Closing directory %s.\n\n", dirname); 42.55 } 42.56 42.57 + printf("End of test.\n"); 42.58 return 0; 42.59 } 42.60
43.1 --- a/tests/dstest_file_client.cc Thu Sep 01 21:40:39 2022 +0200 43.2 +++ b/tests/dstest_file_client.cc Thu Sep 01 21:52:41 2022 +0200 43.3 @@ -111,26 +111,21 @@ 43.4 if (!(*(buffer + nread - 1))) 43.5 printf("Warning: length before zero region is %ld\n", strlen(buffer)); 43.6 43.7 -#if 0 43.8 - for (offset_t i = 0; i < nread; i += 60) 43.9 - { 43.10 - fwrite(buffer + i, sizeof(char), nread - i > 60 ? 60 : nread - i, stdout); 43.11 - fputs("\n", stdout); 43.12 - } 43.13 -#endif 43.14 nread = client_read(file, buffer, size); 43.15 } 43.16 43.17 /* Without any more content, a peer closed event should terminate reading 43.18 - from the pipe. */ 43.19 + from the file. */ 43.20 43.21 if (file->notifications & NOTIFY_PEER_CLOSED) 43.22 break; 43.23 43.24 + /* Otherwise, write some data to the file for the other party. */ 43.25 + 43.26 write_data(file, region++); 43.27 } 43.28 43.29 - printf("Data shown.\n"); 43.30 + printf("Data written: %s\n", region == 26 ? "True" : "False"); 43.31 } 43.32 43.33 int main(int argc, char *argv[]) 43.34 @@ -147,8 +142,10 @@ 43.35 file1 = client_open(filename, O_RDWR | O_CREAT); 43.36 file2 = client_open(filename, O_RDWR); 43.37 43.38 - if ((file1 == NULL) || (file2 == NULL)) 43.39 + if (!client_opened(file1) || !client_opened(file2)) 43.40 { 43.41 + client_close(file1); 43.42 + client_close(file2); 43.43 printf("Could not obtain files.\n"); 43.44 return 1; 43.45 } 43.46 @@ -162,6 +159,8 @@ 43.47 43.48 for (int i = 0; i < 2; i++) 43.49 activities[i]->join(); 43.50 + 43.51 + printf("End of test.\n"); 43.52 } 43.53 43.54 // vim: tabstop=2 expandtab shiftwidth=2
44.1 --- a/tests/dstest_file_mapping.cc Thu Sep 01 21:40:39 2022 +0200 44.2 +++ b/tests/dstest_file_mapping.cc Thu Sep 01 21:52:41 2022 +0200 44.3 @@ -1,5 +1,5 @@ 44.4 /* 44.5 - * Test dataspace operations. 44.6 + * Test manual mapping of dataspace content. 44.7 * 44.8 * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk> 44.9 * 44.10 @@ -109,8 +109,7 @@ 44.11 printf("%s\n", buf); 44.12 } 44.13 44.14 - printf("File shown.\n"); 44.15 - 44.16 + printf("End of test.\n"); 44.17 return 0; 44.18 } 44.19
45.1 --- a/tests/dstest_file_monitor.cc Thu Sep 01 21:40:39 2022 +0200 45.2 +++ b/tests/dstest_file_monitor.cc Thu Sep 01 21:52:41 2022 +0200 45.3 @@ -34,6 +34,12 @@ 45.4 45.5 45.6 45.7 +/* Number of files to open in the test. */ 45.8 + 45.9 +static const int FILES_TO_OPEN = 10; 45.10 + 45.11 + 45.12 + 45.13 /* Open files in the directory given by filename. */ 45.14 45.15 static void open_files(const char *filename) 45.16 @@ -46,7 +52,7 @@ 45.17 return; 45.18 } 45.19 45.20 - for (int i = 0; i < 10; i++) 45.21 + for (int i = 0; i < FILES_TO_OPEN; i++) 45.22 { 45.23 sprintf(buffer, "%s/file%02d", filename, i); 45.24 45.25 @@ -67,7 +73,9 @@ 45.26 return; 45.27 } 45.28 45.29 - while (1) 45.30 + int expected; 45.31 + 45.32 + for (expected = FILES_TO_OPEN; expected; expected--) 45.33 { 45.34 /* Wait for notification of content. */ 45.35 45.36 @@ -81,6 +89,8 @@ 45.37 45.38 printf("Notified with conditions:%s\n", directory->notifications & NOTIFY_FILE_OPENED ? " file opened" : ""); 45.39 } 45.40 + 45.41 + printf("Notified for all expected files: %s\n", expected ? "False" : "True"); 45.42 } 45.43 45.44 45.45 @@ -99,8 +109,9 @@ 45.46 45.47 file_t *directory = client_open(filename, O_DIRECTORY); 45.48 45.49 - if (directory == NULL) 45.50 + if (!client_opened(directory)) 45.51 { 45.52 + client_close(directory); 45.53 printf("Could not open directory.\n"); 45.54 return 1; 45.55 } 45.56 @@ -115,6 +126,8 @@ 45.57 for (int i = 0; i < 2; i++) 45.58 activities[i]->join(); 45.59 45.60 + printf("Expected %d 'file opened' notifications.\n", FILES_TO_OPEN); 45.61 + printf("End of test.\n"); 45.62 return 0; 45.63 } 45.64
46.1 --- a/tests/dstest_file_readdir.cc Thu Sep 01 21:40:39 2022 +0200 46.2 +++ b/tests/dstest_file_readdir.cc Thu Sep 01 21:52:41 2022 +0200 46.3 @@ -34,20 +34,22 @@ 46.4 46.5 int main(int argc, char *argv[]) 46.6 { 46.7 - if (argc < 2) 46.8 + if (argc < 3) 46.9 { 46.10 - printf("Need a directory name.\n"); 46.11 + printf("Need a directory name and an expected number of entries.\n"); 46.12 return 1; 46.13 } 46.14 46.15 char *filename = argv[1]; 46.16 + int entries = atoi(argv[2]); 46.17 46.18 printf("Opening %s...\n", filename); 46.19 46.20 file_t *reader = client_opendir(filename); 46.21 46.22 - if (reader == NULL) 46.23 + if (!client_opened(reader)) 46.24 { 46.25 + client_close(reader); 46.26 printf("Could not read from directory.\n"); 46.27 return 1; 46.28 } 46.29 @@ -55,6 +57,7 @@ 46.30 printf("Reading...\n"); 46.31 46.32 struct dirent *dirent; 46.33 + int found = 0; 46.34 46.35 while ((dirent = client_readdir(reader)) != NULL) 46.36 { 46.37 @@ -69,6 +72,7 @@ 46.38 46.39 if (client_stat(path, &st)) 46.40 { 46.41 + client_close(reader); 46.42 printf("Could not obtain metadata for file: %s\n", dirent->d_name); 46.43 return 1; 46.44 } 46.45 @@ -97,16 +101,19 @@ 46.46 0, 0, ""); 46.47 46.48 free(dirent); 46.49 + found++; 46.50 } 46.51 46.52 printf("Directory shown.\n"); 46.53 + printf("Found expected number of entries: %s\n", found == entries ? "True" : "False"); 46.54 46.55 /* Open again, reading a single entry only. */ 46.56 46.57 reader = client_opendir(filename); 46.58 46.59 - if (reader == NULL) 46.60 + if (!client_opened(reader)) 46.61 { 46.62 + client_close(reader); 46.63 printf("Could not read from directory.\n"); 46.64 return 1; 46.65 } 46.66 @@ -121,6 +128,7 @@ 46.67 46.68 printf("Entry shown.\n"); 46.69 46.70 + printf("End of test.\n"); 46.71 return 0; 46.72 } 46.73
47.1 --- a/tests/dstest_file_readdir_concurrent.cc Thu Sep 01 21:40:39 2022 +0200 47.2 +++ b/tests/dstest_file_readdir_concurrent.cc Thu Sep 01 21:52:41 2022 +0200 47.3 @@ -36,8 +36,11 @@ 47.4 file_t *reader = client_opendir(filename); 47.5 struct dirent *dirent; 47.6 47.7 - if (reader == NULL) 47.8 + if (!client_opened(reader)) 47.9 + { 47.10 + client_close(reader); 47.11 return 1; 47.12 + } 47.13 47.14 *found = 0; 47.15 47.16 @@ -70,7 +73,8 @@ 47.17 47.18 printf("Files found: %d\n", original); 47.19 47.20 - struct dirent *dirent; 47.21 + /* Operate on files with sequence numbering in a certain range. */ 47.22 + 47.23 int filenum_base = 1000, filenum = filenum_base; 47.24 int to_create = 100, remaining = to_create; 47.25 char buffer[strlen(filename) + strlen("/file-XXXX.txt") + 10]; 47.26 @@ -78,16 +82,23 @@ 47.27 int found = 0; 47.28 file_t *files[to_create]; 47.29 47.30 + /* Open a directory for reading. */ 47.31 + 47.32 printf("Opening %s...\n", filename); 47.33 47.34 file_t *reader = client_opendir(filename); 47.35 47.36 - if (reader == NULL) 47.37 + if (!client_opened(reader)) 47.38 { 47.39 + client_close(reader); 47.40 printf("Could not read from directory.\n"); 47.41 return 1; 47.42 } 47.43 47.44 + /* Read entries from the directory. */ 47.45 + 47.46 + struct dirent *dirent; 47.47 + 47.48 printf("Reading...\n"); 47.49 47.50 while ((dirent = client_readdir(reader)) != NULL) 47.51 @@ -103,8 +114,9 @@ 47.52 47.53 file_t *file = client_open(buffer, O_RDWR | O_CREAT); 47.54 47.55 - if (file == NULL) 47.56 + if (!client_opened(file)) 47.57 { 47.58 + client_close(file); 47.59 printf("Could not open file: %s\n", buffer); 47.60 return 1; 47.61 } 47.62 @@ -183,6 +195,7 @@ 47.63 } 47.64 47.65 printf("Files still open: %d (%d)\n", found, to_create); 47.66 + printf("All created files still open: %s\n", found == to_create ? "True" : "False"); 47.67 47.68 /* Close the files. */ 47.69 47.70 @@ -200,7 +213,8 @@ 47.71 } 47.72 47.73 printf("Files found: %d (%d)\n", found, original); 47.74 - 47.75 + printf("Removed all surplus files: %s\n", found == original ? "True" : "False"); 47.76 + printf("End of test.\n"); 47.77 return 0; 47.78 } 47.79
48.1 --- a/tests/dstest_file_remove.cc Thu Sep 01 21:40:39 2022 +0200 48.2 +++ b/tests/dstest_file_remove.cc Thu Sep 01 21:52:41 2022 +0200 48.3 @@ -84,8 +84,9 @@ 48.4 48.5 file = client_open(filename, O_RDONLY); 48.6 48.7 - if (file == NULL) 48.8 + if (!client_opened(file)) 48.9 { 48.10 + client_close(file); 48.11 printf("Could not open file: %s\n", filename); 48.12 return 1; 48.13 } 48.14 @@ -112,7 +113,7 @@ 48.15 48.16 file_t *file_new = client_open(filename, O_RDONLY); 48.17 48.18 - if (file_new != NULL) 48.19 + if (client_opened(file_new)) 48.20 { 48.21 printf("File should be absent: %s\n", filename); 48.22 return 1; 48.23 @@ -120,8 +121,9 @@ 48.24 48.25 file_new = client_open(filename, O_RDWR | O_CREAT); 48.26 48.27 - if (file_new == NULL) 48.28 + if (!client_opened(file_new)) 48.29 { 48.30 + client_close(file_new); 48.31 printf("File should be present: %s\n", filename); 48.32 return 1; 48.33 } 48.34 @@ -138,8 +140,7 @@ 48.35 client_close(file); 48.36 client_close(file_new); 48.37 48.38 - printf("End of tests.\n"); 48.39 - 48.40 + printf("End of test.\n"); 48.41 return 0; 48.42 } 48.43
49.1 --- a/tests/dstest_file_rename.cc Thu Sep 01 21:40:39 2022 +0200 49.2 +++ b/tests/dstest_file_rename.cc Thu Sep 01 21:52:41 2022 +0200 49.3 @@ -38,8 +38,9 @@ 49.4 { 49.5 file_t *reader = client_opendir(filename); 49.6 49.7 - if (reader == NULL) 49.8 + if (!client_opened(reader)) 49.9 { 49.10 + client_close(reader); 49.11 printf("Could not read from directory.\n"); 49.12 return 1; 49.13 } 49.14 @@ -82,8 +83,9 @@ 49.15 49.16 file_t *reader = client_opendir(filename); 49.17 49.18 - if (reader == NULL) 49.19 + if (!client_opened(reader)) 49.20 { 49.21 + client_close(reader); 49.22 printf("Could not read from directory.\n"); 49.23 return 1; 49.24 } 49.25 @@ -138,8 +140,9 @@ 49.26 49.27 reader = client_opendir(filename); 49.28 49.29 - if (reader == NULL) 49.30 + if (!client_opened(reader)) 49.31 { 49.32 + client_close(reader); 49.33 printf("Could not read from directory.\n"); 49.34 return 1; 49.35 } 49.36 @@ -170,8 +173,7 @@ 49.37 if (show_directory(newdir, to_rename)) 49.38 return 1; 49.39 49.40 - printf("End of tests.\n"); 49.41 - 49.42 + printf("End of test.\n"); 49.43 return 0; 49.44 } 49.45
50.1 --- a/tests/dstest_pipe_client.cc Thu Sep 01 21:40:39 2022 +0200 50.2 +++ b/tests/dstest_pipe_client.cc Thu Sep 01 21:52:41 2022 +0200 50.3 @@ -1,7 +1,7 @@ 50.4 /* 50.5 * Test pipe operations. 50.6 * 50.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk> 50.8 + * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk> 50.9 * 50.10 * This program is free software; you can redistribute it and/or 50.11 * modify it under the terms of the GNU General Public License as 50.12 @@ -34,12 +34,18 @@ 50.13 50.14 50.15 50.16 +/* Common size and iteration details. */ 50.17 + 50.18 +const offset_t TO_TRANSFER = 600; 50.19 +const int NUMBER_OF_ITERATIONS = 3; 50.20 + 50.21 + 50.22 + 50.23 /* Use the writer to fill the pipe with data. */ 50.24 50.25 static void write_pipe(file_t *writer, int number) 50.26 { 50.27 - offset_t size = 600; 50.28 - char buffer[size]; 50.29 + char buffer[TO_TRANSFER]; 50.30 long err; 50.31 50.32 /* Make writers blocking to permit synchronisation. */ 50.33 @@ -50,15 +56,15 @@ 50.34 return; 50.35 } 50.36 50.37 - for (int loop = 0; loop < 3; loop++) 50.38 + for (int loop = 0; loop < NUMBER_OF_ITERATIONS; loop++) 50.39 { 50.40 for (int region = 0; region < 26; region++) 50.41 { 50.42 - memset(buffer, (int) 'a' + region, size); 50.43 + memset(buffer, (int) 'a' + region, TO_TRANSFER); 50.44 50.45 - offset_t nwritten = client_write(writer, buffer, size); 50.46 + offset_t nwritten = client_write(writer, buffer, TO_TRANSFER); 50.47 50.48 - printf("Written %ld/%ld in #%d of %d/%d to pipe #%d...\n", nwritten, size, region, loop, 2, number); 50.49 + printf("Written %ld/%ld in #%d of %d/%d to pipe #%d...\n", nwritten, TO_TRANSFER, region, loop, 2, number); 50.50 } 50.51 50.52 sleep(1); 50.53 @@ -73,7 +79,7 @@ 50.54 50.55 static void read_pipes(file_t *reader1, file_t *reader2) 50.56 { 50.57 - offset_t size = 600, totals[] = {0, 0}; 50.58 + offset_t totals[] = {0, 0}; 50.59 unsigned int active = 2; 50.60 long err; 50.61 file_t *reader; 50.62 @@ -93,7 +99,7 @@ 50.63 50.64 while (1) 50.65 { 50.66 - char buffer[size]; 50.67 + char buffer[TO_TRANSFER]; 50.68 offset_t nread; 50.69 50.70 /* Wait for notification of content. */ 50.71 @@ -118,21 +124,14 @@ 50.72 printf("Pipe #%d notified with conditions:%s%s\n", p + 1, reader->notifications & NOTIFY_PEER_CLOSED ? " closed" : "", 50.73 reader->notifications & NOTIFY_CONTENT_AVAILABLE ? " content" : ""); 50.74 50.75 - nread = client_read(reader, buffer, size); 50.76 + nread = client_read(reader, buffer, TO_TRANSFER); 50.77 50.78 while (nread) 50.79 { 50.80 totals[p] += nread; 50.81 50.82 - printf("Read %ld/%ld, total %ld, first %c, last %c, from pipe #%d...\n", nread, size, totals[p], *buffer, *(buffer + nread - 1), p + 1); 50.83 -#if 0 50.84 - for (offset_t i = 0; i < nread; i += 60) 50.85 - { 50.86 - fwrite(buffer + i, sizeof(char), nread - i > 60 ? 60 : nread - i, stdout); 50.87 - fputs("\n", stdout); 50.88 - } 50.89 -#endif 50.90 - nread = client_read(reader, buffer, size); 50.91 + printf("Read %ld/%ld, total %ld, first %c, last %c, from pipe #%d...\n", nread, TO_TRANSFER, totals[p], *buffer, *(buffer + nread - 1), p + 1); 50.92 + nread = client_read(reader, buffer, TO_TRANSFER); 50.93 } 50.94 50.95 /* Without any more content, a peer closed event should terminate reading 50.96 @@ -150,7 +149,11 @@ 50.97 client_close(reader2); 50.98 client_notifier_close(notifier); 50.99 50.100 - printf("Data shown.\n"); 50.101 + for (int p = 0; p < 2; p++) 50.102 + { 50.103 + printf("Data received for pipe #%d: %ld\n", p, totals[p]); 50.104 + printf("Data shown for pipe #%d: %s\n", p, totals[p] == TO_TRANSFER * 26 * NUMBER_OF_ITERATIONS ? "True" : "False"); 50.105 + } 50.106 } 50.107 50.108 int main(void)
51.1 --- a/tests/dstest_test_client.cc Thu Sep 01 21:40:39 2022 +0200 51.2 +++ b/tests/dstest_test_client.cc Thu Sep 01 21:52:41 2022 +0200 51.3 @@ -237,6 +237,8 @@ 51.4 51.5 t = time(NULL) - t; 51.6 printf("Activities completed in %ld seconds (with %ld threads not started).\n", t, errors); 51.7 + printf("All threads started: %s\n", errors ? "False" : "True"); 51.8 + printf("End of test.\n"); 51.9 51.10 return 0; 51.11 }