L4Re/departure

Annotated libfsserver/include/fsserver/opener_context_resource.h

232:9cfd2fb90c33
2022-01-04 Paul Boddie Added initial support for file removal.
paul@93 1
/*
paul@93 2
 * A context resource offering support for 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@94 24
#include <fsserver/opener_context_object_interface.h>
paul@94 25
#include <fsserver/simple_pager.h>
paul@9 26
paul@9 27
paul@9 28
paul@9 29
/* Forward declaration. */
paul@9 30
paul@10 31
class OpenerResource;
paul@9 32
paul@9 33
paul@9 34
paul@9 35
/* Support for indicating files to be opened. */
paul@9 36
paul@10 37
class OpenerContextResource : public SimplePager, public OpenerContextObject
paul@9 38
{
paul@9 39
protected:
paul@10 40
    OpenerResource *_opener;
paul@9 41
paul@9 42
public:
paul@10 43
    explicit OpenerContextResource(OpenerResource *opener, Memory *memory=NULL);
paul@10 44
paul@10 45
    /* Server details. */
paul@10 46
paul@10 47
    int expected_items();
paul@9 48
paul@10 49
    ipc_server_handler_type handler();
paul@10 50
paul@10 51
    void *interface()
paul@10 52
    { return static_cast<OpenerContextObject *>(this); }
paul@10 53
paul@10 54
    /* Data access methods. */
paul@9 55
paul@9 56
    char *get_path();
paul@10 57
paul@10 58
    /* Opener context interface methods. */
paul@10 59
paul@171 60
    long open(flags_t flags, offset_t *size, l4_cap_idx_t *file,
paul@171 61
              object_flags_t *object_flags);
paul@10 62
paul@232 63
    long remove();
paul@232 64
paul@10 65
    /* Pager/dataspace methods. */
paul@10 66
paul@121 67
    long map(unsigned long offset, address_t hot_spot, map_flags_t flags,
paul@10 68
             l4_snd_fpage_t *region)
paul@10 69
    { return SimplePager::map(offset, hot_spot, flags, region); }
paul@10 70
paul@10 71
    long info(unsigned long *size, unsigned long *flags)
paul@10 72
    { return SimplePager::info(size, flags); }
paul@9 73
};
paul@9 74
paul@9 75
// vim: tabstop=4 expandtab shiftwidth=4