# HG changeset patch # User Paul Boddie # Date 1619043136 -7200 # Node ID b7455dda5368225ee0b8eacad78bea585408ba8d # Parent a4cfd888428a2345efab44f428e67744544d5aa7 Added support for testing access to an Ext2 filesystem stored in a host file. diff -r a4cfd888428a -r b7455dda5368 conf/dstest_ext2fs.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/dstest_ext2fs.cfg Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,23 @@ +-- vim:set ft=lua: + +local L4 = require("L4"); + +local l = L4.default_loader; + +local blocksvr = l:new_channel(); + +l:startv({ + caps = { + server = blocksvr:svr(), + }, + log = { "blocksvr", "r" }, + }, + "rom/dstest_block_server", "10"); + +l:startv({ + caps = { + server = blocksvr, + }, + log = { "client", "r" }, + }, + "rom/dstest_ext2fs_client", "server", "rom/e2test.fs"); diff -r a4cfd888428a -r b7455dda5368 conf/dstest_ext2fs.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/dstest_ext2fs.list Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,26 @@ +entry dstest_ext2fs +roottask moe rom/dstest_ext2fs.cfg +module dstest_ext2fs.cfg +module e2test.fs +module l4re +module ned +module dstest_block_server +module dstest_ext2fs_client +module lib4re-c.so +module lib4re-c-util.so +module lib4re.so +module lib4re-util.so +module libc_be_l4refile.so +module libc_be_l4re.so +module libc_be_socket_noop.so +module libc_support_misc.so +module libdl.so +module libipc.so +module libl4sys-direct.so +module libl4sys.so +module libl4util.so +module libld-l4.so +module libpthread.so +module libstdc++.so +module libsupc++.so +module libuc_c.so diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/Control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/Control Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,3 @@ +requires: libc libext2fs libe2access libext2fs_blockserver +provides: libe2access_blockserver +maintainer: paul@boddie.org.uk diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/Makefile Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,4 @@ +PKGDIR ?= . +L4DIR ?= $(PKGDIR)/../../.. + +include $(L4DIR)/mk/subdir.mk diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/include/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/include/Makefile Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,7 @@ +PKGDIR ?= .. +L4DIR ?= $(PKGDIR)/../../.. + +PKGNAME = libe2access_blockserver +CONTRIB_HEADERS = 1 + +include $(L4DIR)/mk/include.mk diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/include/e2access/fs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/include/e2access/fs.h Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,41 @@ +/* + * Filesystem opening functions. + * + * Copyright (C) 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#ifndef __FS_H__ +#define __FS_H__ + +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + +void e2access_init(const char *cap); +errcode_t e2access_open(const char *filename, int flags, ext2_filsys *fs); + +#ifdef __cplusplus +} +#endif + + +#endif /* __FS_H__ */ diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/lib/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/lib/Makefile Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,4 @@ +PKGDIR ?= .. +L4DIR ?= $(PKGDIR)/../../.. + +include $(L4DIR)/mk/subdir.mk diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/lib/src/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/lib/src/Makefile Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,13 @@ +PKGDIR ?= ../.. +L4DIR ?= $(PKGDIR)/../../.. + +TARGET = libe2access_blockserver.a libe2access_blockserver.so +PC_FILENAME = libe2access_blockserver +SRC_C = fs.c + +REQUIRES_LIBS = libext2fs libe2access libext2fs_blockserver + +PRIVATE_INCDIR = $(PKGDIR)/include/e2access +CONTRIB_INCDIR = libe2access_blockserver + +include $(L4DIR)/mk/lib.mk diff -r a4cfd888428a -r b7455dda5368 libe2access_blockserver/lib/src/fs.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libe2access_blockserver/lib/src/fs.c Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,53 @@ +/* + * Filesystem opening functions. + * + * Copyright (C) 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include "fs.h" + + + +/* Block server access configuration. */ + +extern io_manager blockserver_io_manager; +extern const char *blockserver_default_cap; + + + +/* Set the capability name used to access the underlying block server. */ + +void e2access_init(const char *cap) +{ + blockserver_default_cap = cap; +} + +/* Open a filesystem provided by the indicated filename, using the given flags + and updating the filesystem reference. Any error is returned. */ + +errcode_t e2access_open(const char *filename, int flags, ext2_filsys *fs) +{ + errcode_t retval = ext2fs_open(filename, flags, 0, 0, blockserver_io_manager, fs); + + if (retval) + return retval; + + return ext2fs_read_bitmaps(*fs); +} + +// vim: tabstop=2 expandtab shiftwidth=2 diff -r a4cfd888428a -r b7455dda5368 tests/Control --- a/tests/Control Wed Apr 21 23:17:32 2021 +0200 +++ b/tests/Control Thu Apr 22 00:12:16 2021 +0200 @@ -1,3 +1,3 @@ -requires: libstdc++ libc libipc libfsclient libmem +requires: libstdc++ libc libipc libfsclient libmem libext2fs libext2fs_blockserver libe2access_blockserver provides: fstests maintainer: paul@boddie.org.uk diff -r a4cfd888428a -r b7455dda5368 tests/Makefile --- a/tests/Makefile Wed Apr 21 23:17:32 2021 +0200 +++ b/tests/Makefile Thu Apr 22 00:12:16 2021 +0200 @@ -3,6 +3,7 @@ TARGET = \ dstest_block_client dstest_block_client_simple \ + dstest_ext2fs_client \ dstest_host_client \ dstest_pipe_client \ dstest_test_client \ @@ -13,12 +14,14 @@ SRC_CC_dstest_block_client_simple = dstest_block_client_simple.cc +SRC_CC_dstest_ext2fs_client = dstest_ext2fs_client.cc + SRC_CC_dstest_host_client = dstest_host_client.cc SRC_CC_dstest_pipe_client = dstest_pipe_client.cc SRC_CC_dstest_test_client = dstest_test_client.cc -REQUIRES_LIBS = l4re_c-util libfsclient libmem libipc libstdc++ libsystypes +REQUIRES_LIBS = l4re_c-util libfsclient libmem libipc libstdc++ libsystypes libe2access_blockserver include $(L4DIR)/mk/prog.mk diff -r a4cfd888428a -r b7455dda5368 tests/dstest_ext2fs_client.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/dstest_ext2fs_client.cc Thu Apr 22 00:12:16 2021 +0200 @@ -0,0 +1,62 @@ +/* + * Test dataspace operations. + * + * Copyright (C) 2020, 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include + +#include + +#include + +#include + + + +int main(int argc, char *argv[]) +{ + if (argc < 3) + { + printf("Need a device and filename.\n"); + return 1; + } + + /* Obtain device, filename and access parameters. */ + + char *device = argv[1]; + char *filename = argv[2]; + + e2access_init(device); + + ext2_filsys fs = NULL; + + errcode_t retval = e2access_open(filename, EXT2_FLAG_RW, &fs); // EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS + + if (retval) + { + printf("Could not obtain filesystem: %ld.\n", retval); + return 1; + } + + printf("Access completed.\n"); + + return 0; +} + +// vim: tabstop=2 expandtab shiftwidth=2