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