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