L4Re/OLD/libfsserver

Changeset

152:9959e7858160
2020-04-08 Paul Boddie raw files shortlog changelog graph Added a start method to resources, activating accessors in file resources, thus simplifying the open_object_server method by removing the need for it to return an accessor.
include/fsserver/file_resource.h (file) include/fsserver/opener_support.h (file) include/fsserver/resource.h (file) lib/src/opener_support.cc (file) lib/src/resource_server.cc (file)
     1.1 --- a/include/fsserver/file_resource.h	Tue Apr 07 23:30:31 2020 +0200
     1.2 +++ b/include/fsserver/file_resource.h	Wed Apr 08 21:24:56 2020 +0200
     1.3 @@ -63,6 +63,11 @@
     1.4  
     1.5    virtual void close();
     1.6  
     1.7 +  /* Activation. */
     1.8 +
     1.9 +  virtual void start()
    1.10 +  { _accessor->attach(); }
    1.11 +
    1.12    /* Operation methods. */
    1.13  
    1.14    virtual long begin(size_t *size);
     2.1 --- a/include/fsserver/opener_support.h	Tue Apr 07 23:30:31 2020 +0200
     2.2 +++ b/include/fsserver/opener_support.h	Wed Apr 08 21:24:56 2020 +0200
     2.3 @@ -53,13 +53,12 @@
     2.4    virtual long open_object(fs_object_t *fsobj, int flags, size_t *size,
     2.5                             l4_cap_idx_t *file);
     2.6  
     2.7 -  /* A mechanism for obtaining accessors and servers for filesystem objects. */
     2.8 +  /* A mechanism for obtaining servers for filesystem objects. */
     2.9  
    2.10    virtual long open_object_server(fs_object_t *fsobj, int flags,
    2.11 -                                  Accessor **accessor,
    2.12                                    ResourceServer **server)
    2.13    {
    2.14 -    (void) fsobj; (void) flags; (void) accessor; (void) server;
    2.15 +    (void) fsobj; (void) flags; (void) server;
    2.16      return -L4_EACCESS;
    2.17    }
    2.18  };
     3.1 --- a/include/fsserver/resource.h	Tue Apr 07 23:30:31 2020 +0200
     3.2 +++ b/include/fsserver/resource.h	Wed Apr 08 21:24:56 2020 +0200
     3.3 @@ -37,4 +37,10 @@
     3.4    virtual void close()
     3.5    {
     3.6    }
     3.7 +
     3.8 +  /* Activation. */
     3.9 +
    3.10 +  virtual void start()
    3.11 +  {
    3.12 +  }
    3.13  };
     4.1 --- a/lib/src/opener_support.cc	Tue Apr 07 23:30:31 2020 +0200
     4.2 +++ b/lib/src/opener_support.cc	Wed Apr 08 21:24:56 2020 +0200
     4.3 @@ -28,9 +28,8 @@
     4.4  long OpenerSupport::open_object(fs_object_t *fsobj, int flags,
     4.5                                  size_t *size, l4_cap_idx_t *file)
     4.6  {
     4.7 -  Accessor *accessor;
     4.8    ResourceServer *server;
     4.9 -  long err = open_object_server(fsobj, flags, &accessor, &server);
    4.10 +  long err = open_object_server(fsobj, flags, &server);
    4.11  
    4.12    if (err)
    4.13      return err;
    4.14 @@ -40,10 +39,6 @@
    4.15    if (err)
    4.16      return err;
    4.17  
    4.18 -  /* Attach to the accessor. */
    4.19 -
    4.20 -  accessor->attach();
    4.21 -  
    4.22    /* Return the file size. */
    4.23    /* Return the server capability to the caller. */
    4.24    
     5.1 --- a/lib/src/resource_server.cc	Tue Apr 07 23:30:31 2020 +0200
     5.2 +++ b/lib/src/resource_server.cc	Wed Apr 08 21:24:56 2020 +0200
     5.3 @@ -1,7 +1,7 @@
     5.4  /*
     5.5   * Resource server functionality.
     5.6   *
     5.7 - * Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
     5.8 + * Copyright (C) 2018, 2019, 2020 Paul Boddie <paul@boddie.org.uk>
     5.9   *
    5.10   * This program is free software; you can redistribute it and/or
    5.11   * modify it under the terms of the GNU General Public License as
    5.12 @@ -54,12 +54,24 @@
    5.13  
    5.14  long ResourceServer::start()
    5.15  {
    5.16 -  return resource_start(this, 0);
    5.17 +  long err = resource_start(this, 0);
    5.18 +
    5.19 +  if (err)
    5.20 +    return err;
    5.21 +
    5.22 +  _resource->start();
    5.23 +  return L4_EOK;
    5.24  }
    5.25  
    5.26  long ResourceServer::start_thread()
    5.27  {
    5.28 -  return resource_start(this, 1);
    5.29 +  long err = resource_start(this, 1);
    5.30 +
    5.31 +  if (err)
    5.32 +    return err;
    5.33 +
    5.34 +  _resource->start();
    5.35 +  return L4_EOK;
    5.36  }
    5.37  
    5.38