L4Re/departure

Annotated libfsserver/include/fsserver/file_object_registry.h

218:20d95266049c
2021-10-16 Paul Boddie Made the file registry responsible for looking up existing objects and obtaining resources through a single get_resource operation, simplifying the opener resource.
paul@93 1
/*
paul@200 2
 * A registry of filesystem objects.
paul@93 3
 *
paul@93 4
 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
paul@93 5
 *
paul@93 6
 * This program is free software; you can redistribute it and/or
paul@93 7
 * modify it under the terms of the GNU General Public License as
paul@93 8
 * published by the Free Software Foundation; either version 2 of
paul@93 9
 * the License, or (at your option) any later version.
paul@93 10
 *
paul@93 11
 * This program is distributed in the hope that it will be useful,
paul@93 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@93 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@93 14
 * GNU General Public License for more details.
paul@93 15
 *
paul@93 16
 * You should have received a copy of the GNU General Public License
paul@93 17
 * along with this program; if not, write to the Free Software
paul@93 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@93 19
 * Boston, MA  02110-1301, USA
paul@93 20
 */
paul@93 21
paul@9 22
#pragma once
paul@9 23
paul@202 24
#include <fsserver/directory_provider.h>
paul@144 25
#include <fsserver/file_opening.h>
paul@200 26
#include <fsserver/file_provider.h>
paul@202 27
#include <fsserver/file_registry.h>
paul@94 28
#include <fsserver/pager.h>
paul@144 29
#include <fsserver/pages.h>
paul@9 30
paul@9 31
paul@9 32
paul@200 33
/* A registry of filesystem objects. */
paul@9 34
paul@209 35
class FileObjectRegistry : public FileRegistry
paul@9 36
{
paul@9 37
protected:
paul@79 38
    Pages *_pages;
paul@9 39
paul@202 40
    /* Resource initialisation methods. */
paul@144 41
paul@144 42
    map_flags_t get_flags(flags_t flags);
paul@144 43
paul@202 44
    long get_directory_provider(FileOpening *opening, const char *path,
paul@202 45
                                flags_t flags, fileid_t fileid,
paul@202 46
                                DirectoryProvider **directory_provider);
paul@202 47
paul@202 48
    long get_file_provider(FileOpening *opening, const char *path,
paul@202 49
                           flags_t flags, fileid_t fileid,
paul@202 50
                           FileProvider **file_provider);
paul@193 51
paul@218 52
    /* Resource initialisation methods. */
paul@218 53
paul@218 54
    long get_directory(FileOpening *opening, const char *path, flags_t flags,
paul@218 55
                       fileid_t fileid, offset_t *size, object_flags_t *object_flags,
paul@218 56
                       Resource **resource);
paul@218 57
paul@218 58
    long get_file(FileOpening *opening, const char *path, flags_t flags,
paul@218 59
                  fileid_t fileid, offset_t *size, object_flags_t *object_flags,
paul@218 60
                  Resource **resource);
paul@218 61
paul@79 62
public:
paul@209 63
    explicit FileObjectRegistry(Pages *pages);
paul@79 64
paul@208 65
    /* Resource discovery methods. */
paul@208 66
paul@208 67
    long find_directory_provider(fileid_t fileid,
paul@208 68
                                 DirectoryProvider **directory_provider);
paul@208 69
paul@202 70
    /* Resource initialisation methods. */
paul@144 71
paul@218 72
    long get_resource(FileOpening *opening, const char *path, flags_t flags,
paul@218 73
                      offset_t *size, object_flags_t *object_flags,
paul@218 74
                      Resource **resource);
paul@9 75
};
paul@9 76
paul@9 77
// vim: tabstop=4 expandtab shiftwidth=4