L4Re/departure

Annotated libfsserver/include/fsserver/opener_resource.h

211:dc521e9dbd13
2021-10-02 Paul Boddie Added tentative support for directory-level notifications.
paul@93 1
/*
paul@93 2
 * A resource offering support for creating contexts and opening files.
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@209 24
#include <fsserver/file_object_registry.h>
paul@144 25
#include <fsserver/file_opening.h>
paul@94 26
#include <fsserver/opener_context_resource.h>
paul@94 27
#include <fsserver/opener_interface.h>
paul@94 28
#include <fsserver/resource.h>
paul@9 29
paul@93 30
paul@93 31
paul@9 32
/* Support for providing access to files. */
paul@9 33
paul@144 34
class OpenerResource : public Resource, public FileOpening, public Opener
paul@9 35
{
paul@144 36
protected:
paul@209 37
    FileObjectRegistry *_registry;
paul@144 38
paul@156 39
    /* Convenience methods determining different object types. */
paul@156 40
paul@156 41
    virtual bool accessing_directory(const char *path, flags_t flags, fileid_t fileid) = 0;
paul@156 42
paul@156 43
    virtual bool accessing_file(const char *path, flags_t flags, fileid_t fileid) = 0;
paul@156 44
paul@202 45
    /* Convenience methods obtaining different resource types. */
paul@156 46
paul@171 47
    virtual long get_directory(const char *path, flags_t flags, fileid_t fileid,
paul@171 48
                               offset_t *size, l4_cap_idx_t *cap,
paul@171 49
                               object_flags_t *object_flags);
paul@157 50
paul@171 51
    virtual long get_file(const char *path, flags_t flags, fileid_t fileid,
paul@171 52
                          offset_t *size, l4_cap_idx_t *cap,
paul@171 53
                          object_flags_t *object_flags);
paul@156 54
paul@211 55
    /* Notification methods. */
paul@211 56
paul@211 57
    virtual long notify_parent(const char *path);
paul@211 58
paul@9 59
public:
paul@209 60
    explicit OpenerResource(FileObjectRegistry *registry);
paul@10 61
paul@156 62
    virtual ~OpenerResource();
paul@156 63
paul@10 64
    /* Server details. */
paul@10 65
paul@10 66
    int expected_items();
paul@9 67
paul@10 68
    ipc_server_handler_type handler();
paul@10 69
paul@10 70
    void *interface()
paul@10 71
    { return static_cast<Opener *>(this); }
paul@10 72
paul@10 73
    /* Direct access methods. */
paul@9 74
paul@171 75
    long open(const char *path, flags_t flags, offset_t *size,
paul@171 76
              l4_cap_idx_t *cap, object_flags_t *object_flags);
paul@10 77
paul@10 78
    /* Opener interface methods. */
paul@10 79
paul@10 80
    long context(l4_cap_idx_t *context);
paul@9 81
};
paul@9 82
paul@9 83
// vim: tabstop=4 expandtab shiftwidth=4