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 "ext2_file_opener.h" 24 #include "ext2_filesystem.h" 25 #include "resource_server.h" 26 27 Ext2Filesystem::Ext2Filesystem(Pages *pages, ext2_filsys fs) 28 : FilesystemResource(pages) 29 { 30 _ops = new Ext2FileOperations(fs); 31 } 32 33 Ext2Filesystem::~Ext2Filesystem() 34 { 35 delete _ops; 36 } 37 38 /* Return a file opener object for the given user. */ 39 40 long Ext2Filesystem::open_for_user(sys_uid_t uid, sys_gid_t gid, 41 sys_mode_t umask, l4_cap_idx_t *ref) 42 { 43 user_t user = (user_t) {uid, gid, umask}; 44 Resource *resource = new Ext2FileOpener(this, _ops, user); 45 46 /* Complete the initialisation and start a server in a new thread. 47 If the thread does not start, the resource will be finalised. */ 48 49 return ResourceServer(resource).start_thread(ref); 50 } 51 52 // vim: tabstop=4 expandtab shiftwidth=4