L4Re/departure

Change of libfsserver/lib/files/file_object_registry.cc

221:5800bd1b5ca5
libfsserver/lib/files/file_object_registry.cc
     1.1 --- a/libfsserver/lib/files/file_object_registry.cc	Sun Oct 17 18:48:30 2021 +0200
     1.2 +++ b/libfsserver/lib/files/file_object_registry.cc	Sun Oct 17 21:55:37 2021 +0200
     1.3 @@ -61,7 +61,7 @@
     1.4      if (err)
     1.5          return err;
     1.6  
     1.7 -    *provider = new DirectoryProvider(accessor);
     1.8 +    *provider = new DirectoryProvider(fileid, this, accessor);
     1.9  
    1.10      /* Register the provider. */
    1.11  
    1.12 @@ -85,7 +85,7 @@
    1.13          return err;
    1.14  
    1.15      PageMapper *mapper = new PageMapper(accessor, _pages);
    1.16 -    *provider = new FileProvider(mapper);
    1.17 +    *provider = new FileProvider(fileid, get_flags(flags), this, mapper);
    1.18  
    1.19      /* Register the provider. */
    1.20  
    1.21 @@ -110,72 +110,6 @@
    1.22  
    1.23  
    1.24  
    1.25 -/* Return a directory resource initialised with a provider. */
    1.26 -
    1.27 -long FileObjectRegistry::make_directory_resource(fileid_t fileid, offset_t *size,
    1.28 -                                                 object_flags_t *object_flags,
    1.29 -                                                 DirectoryProvider *provider,
    1.30 -                                                 Resource **resource)
    1.31 -{
    1.32 -    /* Provide non-file values for certain outputs. */
    1.33 -
    1.34 -    *size = 0;
    1.35 -    *object_flags = 0;
    1.36 -
    1.37 -    /* Initialise the resource with the provider and a reference to this object
    1.38 -       for detaching from the provider. */
    1.39 -
    1.40 -    provider->attach();
    1.41 -    *resource = new DirectoryResource(fileid, provider, this);
    1.42 -    return L4_EOK;
    1.43 -}
    1.44 -
    1.45 -/* Return a file pager initialised with a provider, page mapper and accessor. */
    1.46 -
    1.47 -long FileObjectRegistry::make_file_resource(flags_t flags, fileid_t fileid,
    1.48 -                                            offset_t *size,
    1.49 -                                            object_flags_t *object_flags,
    1.50 -                                            FileProvider *provider,
    1.51 -                                            Resource **resource)
    1.52 -{
    1.53 -    /* Initialise the pager with the provider and a reference to this object for
    1.54 -       detaching from the provider. */
    1.55 -
    1.56 -    FilePager *pager = new FilePager(fileid, provider, get_flags(flags), this);
    1.57 -
    1.58 -    /* Obtain the size details from the pager, also providing appropriate
    1.59 -       flags. */
    1.60 -
    1.61 -    *size = pager->get_data_size();
    1.62 -    *object_flags = OBJECT_SUPPORTS_MMAP | OBJECT_HAS_SIZE;
    1.63 -
    1.64 -    provider->attach();
    1.65 -    *resource = pager;
    1.66 -    return L4_EOK;
    1.67 -}
    1.68 -
    1.69 -/* Make a resource of the appropriate type. */
    1.70 -
    1.71 -long FileObjectRegistry::make_resource(flags_t flags, fileid_t fileid,
    1.72 -                                       offset_t *size,
    1.73 -                                       object_flags_t *object_flags,
    1.74 -                                       Provider *provider, Resource **resource)
    1.75 -{
    1.76 -    DirectoryProvider *dp = dynamic_cast<DirectoryProvider *>(provider);
    1.77 -
    1.78 -    if (dp != NULL)
    1.79 -        return make_directory_resource(fileid, size, object_flags, dp, resource);
    1.80 -
    1.81 -    FileProvider *fp = dynamic_cast<FileProvider *>(provider);
    1.82 -
    1.83 -    if (fp != NULL)
    1.84 -        return make_file_resource(flags, fileid, size, object_flags, fp, resource);
    1.85 -
    1.86 -    return -L4_EIO;
    1.87 -}
    1.88 -
    1.89 -
    1.90 -
    1.91  /* Return a resource for a filesystem object. */
    1.92  
    1.93  long FileObjectRegistry::get_resource(FileOpening *opening, const char *path,
    1.94 @@ -209,7 +143,7 @@
    1.95  
    1.96      /* Make a resource for the provider. */
    1.97  
    1.98 -    return make_resource(flags, fileid, size, object_flags, provider, resource);
    1.99 +    return provider->make_resource(size, object_flags, resource);
   1.100  }
   1.101  
   1.102