1.1 --- a/include/fs_directory.h Fri Jan 31 22:51:52 2020 +0100
1.2 +++ b/include/fs_directory.h Sat Feb 01 17:33:10 2020 +0100
1.3 @@ -27,6 +27,10 @@
1.4 #include <fsserver/paging.h>
1.5 #include <fsserver/resource.h>
1.6
1.7 +/* Interface support. */
1.8 +
1.9 +#include <fsserver/opener_support.h>
1.10 +
1.11 /* Common interface. */
1.12
1.13 #include <fsserver/directory_object_interface.h>
1.14 @@ -35,7 +39,8 @@
1.15
1.16 /* Filesystem directory resource. */
1.17
1.18 -class Fs_directory : public Resource, public DirectoryObject
1.19 +class Fs_directory : public Resource, public DirectoryObject,
1.20 + public OpenerSupport
1.21 {
1.22 private:
1.23 ext2_filsys _fs;
1.24 @@ -63,7 +68,18 @@
1.25 {
1.26 }
1.27
1.28 - /* Operation methods. */
1.29 + /* Open operation delegation. */
1.30 +
1.31 + virtual long open(int flags, l4_cap_idx_t ds, l4_cap_idx_t irq,
1.32 + size_t *size, l4_cap_idx_t *file)
1.33 + {
1.34 + return OpenerSupport::open(flags, ds, irq, size, file);
1.35 + }
1.36
1.37 - long listdir(int flags, l4_cap_idx_t ds, l4_cap_idx_t irq, size_t *size, l4_cap_idx_t *dir);
1.38 + /* A mechanism for obtaining accessors and servers for filesystem objects.
1.39 + Here, it supports the opening of a directory listing. */
1.40 +
1.41 + virtual long open_object_server(fs_object_t *fsobj, int flags,
1.42 + Notifier **accessor,
1.43 + ResourceServer **server);
1.44 };
2.1 --- a/include/fs_directory_listing.h Fri Jan 31 22:51:52 2020 +0100
2.2 +++ b/include/fs_directory_listing.h Sat Feb 01 17:33:10 2020 +0100
2.3 @@ -92,7 +92,7 @@
2.4
2.5 pthread_t _thread;
2.6 l4_cap_idx_t _thread_ep;
2.7 - bool _terminating;
2.8 + bool _terminating = false;
2.9
2.10 public:
2.11 explicit Fs_directory_listing(ext2_filsys fs, ext2_ino_t dir, int flags=0)
3.1 --- a/include/fs_user_filesystem.h Fri Jan 31 22:51:52 2020 +0100
3.2 +++ b/include/fs_user_filesystem.h Sat Feb 01 17:33:10 2020 +0100
3.3 @@ -63,7 +63,8 @@
3.4 {
3.5 }
3.6
3.7 - /* A mechanism for obtaining accessors and servers for filesystem objects. */
3.8 + /* A mechanism for obtaining accessors and servers for filesystem objects.
3.9 + Here, the default is overridden with an e2fs-specific implementation. */
3.10
3.11 virtual long open_object_server(fs_object_t *fsobj, int flags,
3.12 Notifier **accessor,
4.1 --- a/server/src/fs_directory.cc Fri Jan 31 22:51:52 2020 +0100
4.2 +++ b/server/src/fs_directory.cc Sat Feb 01 17:33:10 2020 +0100
4.3 @@ -19,11 +19,6 @@
4.4 * Boston, MA 02110-1301, USA
4.5 */
4.6
4.7 -#include <l4/re/c/rm.h>
4.8 -#include <l4/sys/types.h>
4.9 -
4.10 -#include <stdio.h>
4.11 -
4.12 #include <fsserver/file_resource.h>
4.13 #include <fsserver/file_resource_server.h>
4.14 #include "fs_directory_listing_accessor.h"
4.15 @@ -38,60 +33,30 @@
4.16 return new Fs_directory_listing_accessor(_fs, _dir, flags, _paging->pages());
4.17 }
4.18
4.19 -/* Obtain a directory listing reference. */
4.20 -
4.21 -long Fs_directory::listdir(int flags, l4_cap_idx_t ds, l4_cap_idx_t irq, size_t *size, l4_cap_idx_t *dir)
4.22 -{
4.23 - fs_object_t fsobj;
4.24 - long err;
4.25 -
4.26 - /* Obtain the dataspace and IRQ object. */
4.27 +/* Obtain an accessor and resource server for a directory listing. */
4.28
4.29 - fsobj.ds = ds;
4.30 - fsobj.irq = irq;
4.31 - fsobj.buffer_size = l4re_ds_size(ds);
4.32 -
4.33 - err = l4re_rm_attach((void **) &fsobj.buffer, fsobj.buffer_size,
4.34 - L4RE_RM_SEARCH_ADDR, fsobj.ds, 0, L4_PAGESHIFT);
4.35 - if (err)
4.36 - return err;
4.37 -
4.38 +long Fs_directory::open_object_server(fs_object_t *fsobj, int flags,
4.39 + Notifier **accessor,
4.40 + ResourceServer **server)
4.41 +{
4.42 /* Obtain an accessor for the listing. */
4.43
4.44 - Accessor *accessor = dynamic_cast<Accessor *>(_get_accessor(flags));
4.45 + Accessor *dir_accessor = dynamic_cast<Accessor *>(_get_accessor(flags));
4.46
4.47 /* Send an error for unsupported objects. */
4.48
4.49 - if (!accessor)
4.50 + if (!dir_accessor)
4.51 return -L4_EIO;
4.52
4.53 /* Populate the size member of the common object structure. */
4.54
4.55 - fsobj.size = accessor->get_size();
4.56 + fsobj->size = dir_accessor->get_size();
4.57
4.58 /* Create a new object. */
4.59
4.60 - MappedFileResource *resource = new MappedFileResource(accessor, fsobj);
4.61 - ResourceServer *server = new MappedFileServer(resource);
4.62 -
4.63 - /* Configure the dedicated thread for the object. */
4.64 + MappedFileResource *resource = new MappedFileResource(dir_accessor, *fsobj);
4.65 + *server = new MappedFileServer(resource);
4.66 + *accessor = dir_accessor;
4.67
4.68 - err = server->start_thread();
4.69 - if (err)
4.70 - {
4.71 - server->close();
4.72 - delete server;
4.73 - return err;
4.74 - }
4.75 -
4.76 - /* Register the object for notifications. */
4.77 -
4.78 - if (accessor)
4.79 - accessor->attach(fsobj.irq);
4.80 -
4.81 - /* Return the file size and the server capability to the caller. */
4.82 -
4.83 - *size = fsobj.size;
4.84 - *dir = server->cap();
4.85 return L4_EOK;
4.86 }
5.1 --- a/server/src/fs_directory_listing.cc Fri Jan 31 22:51:52 2020 +0100
5.2 +++ b/server/src/fs_directory_listing.cc Sat Feb 01 17:33:10 2020 +0100
5.3 @@ -434,6 +434,10 @@
5.4 l4_umword_t label = 0;
5.5 ipc_message_t msg;
5.6
5.7 + /* Provide item expectations for the message. */
5.8 +
5.9 + ipc_message_expect(&msg, DirectoryListingPrivate_expected_items);
5.10 +
5.11 while ((label & ~3UL) != l4_umword_t(this))
5.12 ipc_message_wait(&msg, &label);
5.13
6.1 --- a/server/src/fs_user_filesystem.cc Fri Jan 31 22:51:52 2020 +0100
6.2 +++ b/server/src/fs_user_filesystem.cc Sat Feb 01 17:33:10 2020 +0100
6.3 @@ -19,7 +19,6 @@
6.4 * Boston, MA 02110-1301, USA
6.5 */
6.6
6.7 -#include <l4/re/c/rm.h>
6.8 #include <l4/sys/types.h>
6.9 #include <l4/util/util.h>
6.10