paul@105 | 1 | /* |
paul@105 | 2 | * Filesystem opening functions. |
paul@105 | 3 | * |
paul@105 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@105 | 5 | * |
paul@105 | 6 | * This program is free software; you can redistribute it and/or |
paul@105 | 7 | * modify it under the terms of the GNU General Public License as |
paul@105 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@105 | 9 | * the License, or (at your option) any later version. |
paul@105 | 10 | * |
paul@105 | 11 | * This program is distributed in the hope that it will be useful, |
paul@105 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@105 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@105 | 14 | * GNU General Public License for more details. |
paul@105 | 15 | * |
paul@105 | 16 | * You should have received a copy of the GNU General Public License |
paul@105 | 17 | * along with this program; if not, write to the Free Software |
paul@105 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@105 | 19 | * Boston, MA 02110-1301, USA |
paul@105 | 20 | */ |
paul@105 | 21 | |
paul@105 | 22 | #include "fs.h" |
paul@105 | 23 | |
paul@105 | 24 | |
paul@105 | 25 | |
paul@105 | 26 | /* Block server access configuration. */ |
paul@105 | 27 | |
paul@105 | 28 | extern io_manager blockserver_io_manager; |
paul@105 | 29 | extern const char *blockserver_default_cap; |
paul@105 | 30 | |
paul@105 | 31 | |
paul@105 | 32 | |
paul@105 | 33 | /* Set the capability name used to access the underlying block server. */ |
paul@105 | 34 | |
paul@105 | 35 | void e2access_init(const char *cap) |
paul@105 | 36 | { |
paul@105 | 37 | blockserver_default_cap = cap; |
paul@105 | 38 | } |
paul@105 | 39 | |
paul@105 | 40 | /* Open a filesystem provided by the indicated filename, using the given flags |
paul@105 | 41 | and updating the filesystem reference. Any error is returned. */ |
paul@105 | 42 | |
paul@105 | 43 | errcode_t e2access_open(const char *filename, int flags, ext2_filsys *fs) |
paul@105 | 44 | { |
paul@105 | 45 | errcode_t retval = ext2fs_open(filename, flags, 0, 0, blockserver_io_manager, fs); |
paul@105 | 46 | |
paul@105 | 47 | if (retval) |
paul@105 | 48 | return retval; |
paul@105 | 49 | |
paul@105 | 50 | return ext2fs_read_bitmaps(*fs); |
paul@105 | 51 | } |
paul@105 | 52 | |
paul@105 | 53 | // vim: tabstop=2 expandtab shiftwidth=2 |