1 /* 2 * File operations supporting an Ext2-compatible filesystem. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <ext2fs/ext2fs.h> 25 26 #include <systypes/base.h> 27 #include <systypes/user.h> 28 29 30 31 /* An Ext2 file operations collection. */ 32 33 class Ext2FileOperations 34 { 35 protected: 36 ext2_filsys _fs; 37 38 public: 39 explicit Ext2FileOperations(ext2_filsys fs) 40 : _fs(fs) 41 { 42 } 43 44 long create_file(ext2_ino_t ino_parent, const char *filename, user_t user, 45 ext2_ino_t *ino); 46 47 long find_file(const char *path, ext2_ino_t *ino, const char **remaining); 48 49 void close_file(ext2_file_t file); 50 51 long open_file(ext2_ino_t ino, ext2_file_t *file); 52 53 offset_t get_size(ext2_file_t file); 54 55 void set_size(ext2_file_t file, offset_t size); 56 57 offset_t read_file(ext2_file_t file, offset_t filepos, void *addr, offset_t size); 58 59 void write_file(ext2_file_t file, offset_t filepos, const void *addr, offset_t size); 60 }; 61 62 // vim: tabstop=4 expandtab shiftwidth=4