1 /* 2 * A user-configured filesystem server. 3 * 4 * Copyright (C) 2018, 2019 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 <l4/sys/types.h> 25 26 #include <ext2fs/ext2fs.h> 27 28 #include <fsserver/resource.h> 29 #include <ipc/util_ipc.h> 30 #include <systypes/user.h> 31 32 33 34 /* Filesystem server for a specific user identity. */ 35 36 class Fs_user_server : public Resource 37 { 38 private: 39 ext2_filsys _fs; 40 const char *_devname; 41 user_t _user; 42 l4_cap_idx_t _server = L4_INVALID_CAP; 43 44 protected: 45 int _can_read(struct ext2_inode *inode); 46 47 int _can_write(struct ext2_inode *inode); 48 49 public: 50 51 /* Initialise the user server, with the underlying resource receiving the IRQ 52 and being configured to expect one item. */ 53 54 explicit Fs_user_server(ext2_filsys fs, const char *devname, user_t user, 55 l4_cap_idx_t irq) 56 : Resource(irq, 1), _fs(fs), _devname(devname), _user(user) 57 { 58 } 59 60 void set_server(l4_cap_idx_t server); 61 62 void dispatch(ipc_message_t *msg); 63 64 void open(ipc_message_t *msg); 65 66 void getfs(ipc_message_t *msg); 67 };