1 /* 2 * A resource supporting the creation of user-specific ext2 filesystem opener 3 * resources. 4 * 5 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA 21 */ 22 23 #include <resource/resource_server.h> 24 25 #include "ext2_file_opener.h" 26 #include "ext2_filesystem.h" 27 28 Ext2Filesystem::Ext2Filesystem(Pages *pages, ext2_filsys fs) 29 : FilesystemResource(pages) 30 { 31 _ops = new Ext2FileOperations(fs); 32 } 33 34 Ext2Filesystem::~Ext2Filesystem() 35 { 36 delete _ops; 37 } 38 39 /* Return a file opener object for the given user details. */ 40 41 long Ext2Filesystem::open_for_user(ipc_varg_sys_uid_t uid, ipc_varg_sys_gid_t gid, 42 ipc_varg_sys_mode_t umask, l4_cap_idx_t *ref) 43 { 44 user_t user = (user_t) {uid.value, gid.value, umask.value}; 45 46 return open_for_user(user, ref); 47 } 48 49 /* Return a file opener object for the given user. */ 50 51 long Ext2Filesystem::open_for_user(user_t user, l4_cap_idx_t *ref) 52 { 53 Resource *resource = new Ext2FileOpener(this, _ops, user); 54 55 /* Complete the initialisation and start a server in a new thread. 56 If the thread does not start, the resource will be finalised. */ 57 58 return ResourceServer(resource).start_thread(ref); 59 } 60 61 // vim: tabstop=4 expandtab shiftwidth=4