L4Re/departure

Annotated libfsserver/lib/directories/directory_provider.cc

645:3047b11cc814
7 months ago Paul Boddie Fixed the file_data_available result to return zero if the populated span has somehow become less than the current position in the memory region.
paul@202 1
/*
paul@202 2
 * An object providing access to directory functionality.
paul@202 3
 *
paul@330 4
 * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
paul@202 5
 *
paul@202 6
 * This program is free software; you can redistribute it and/or
paul@202 7
 * modify it under the terms of the GNU General Public License as
paul@202 8
 * published by the Free Software Foundation; either version 2 of
paul@202 9
 * the License, or (at your option) any later version.
paul@202 10
 *
paul@202 11
 * This program is distributed in the hope that it will be useful,
paul@202 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@202 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@202 14
 * GNU General Public License for more details.
paul@202 15
 *
paul@202 16
 * You should have received a copy of the GNU General Public License
paul@202 17
 * along with this program; if not, write to the Free Software
paul@202 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@202 19
 * Boston, MA  02110-1301, USA
paul@202 20
 */
paul@202 21
paul@202 22
#include "directory_provider.h"
paul@221 23
#include "directory_resource.h"
paul@202 24
paul@202 25
paul@202 26
paul@202 27
/* Initialise the provider. */
paul@202 28
paul@224 29
DirectoryProvider::DirectoryProvider(fileid_t fileid,
paul@224 30
                                     ProviderRegistry *registry,
paul@221 31
                                     DirectoryAccessor *accessor)
paul@221 32
: Provider(fileid, registry), _accessor(accessor)
paul@202 33
{
paul@202 34
}
paul@202 35
paul@202 36
/* Deallocate the provider's resources. */
paul@202 37
paul@202 38
DirectoryProvider::~DirectoryProvider()
paul@202 39
{
paul@202 40
}
paul@202 41
paul@202 42
/* Return the accessor. */
paul@202 43
paul@202 44
DirectoryAccessor *DirectoryProvider::accessor()
paul@202 45
{
paul@202 46
    return _accessor;
paul@202 47
}
paul@202 48
paul@221 49
/* Return a directory resource initialised with this provider. */
paul@221 50
paul@330 51
long DirectoryProvider::make_resource(flags_t flags, offset_t *size,
paul@221 52
                                      object_flags_t *object_flags,
paul@221 53
                                      Resource **resource)
paul@221 54
{
paul@330 55
    (void) flags;
paul@330 56
paul@221 57
    /* Provide non-file values for certain outputs. */
paul@221 58
paul@221 59
    *size = 0;
paul@221 60
    *object_flags = 0;
paul@221 61
paul@221 62
    /* Initialise the resource with the provider and a reference to the registry
paul@221 63
       for detaching from the provider. */
paul@221 64
paul@221 65
    this->attach();
paul@222 66
    *resource = new DirectoryResource(_fileid, this);
paul@221 67
    return L4_EOK;
paul@221 68
}
paul@221 69
paul@202 70
// vim: tabstop=4 expandtab shiftwidth=4