1 /* 2 * A context resource offering support for opening files. 3 * 4 * Copyright (C) 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <fsserver/opener_context_object_interface.h> 25 #include <fsserver/simple_pager.h> 26 27 28 29 /* Forward declaration. */ 30 31 class OpenerResource; 32 33 34 35 /* Support for indicating files to be opened. */ 36 37 class OpenerContextResource : public SimplePager, public OpenerContextObject 38 { 39 protected: 40 OpenerResource *_opener; 41 42 public: 43 explicit OpenerContextResource(OpenerResource *opener, Memory *memory=NULL); 44 45 /* Server details. */ 46 47 ipc_server_default_config_type config(); 48 49 void *interface() 50 { return static_cast<OpenerContextObject *>(this); } 51 52 /* Opener context interface methods. */ 53 54 long mkdir(sys_mode_t mode); 55 56 long open(flags_t flags, offset_t *size, l4_cap_idx_t *file, 57 object_flags_t *object_flags); 58 59 long remove(); 60 61 long rename(); 62 63 long stat(); 64 65 /* Pager/dataspace methods. */ 66 67 long map(offset_t offset, map_address_t hot_spot, map_flags_t flags, 68 l4_snd_fpage_t *region) 69 { return SimplePager::map(offset, hot_spot, flags, region); } 70 71 long info(offset_t *size, map_flags_t *flags) 72 { return SimplePager::info(size, flags); } 73 }; 74 75 // vim: tabstop=4 expandtab shiftwidth=4