/* Calcite, src/kernel/fs.h * Copyright 2025 Benji Dial * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #pragma once #include "drives.h" #include #include struct fs_stat { uint64_t bytes; }; struct fs_info { const struct drive_info *drive; const void *driver_info; enum fs_access_result (*free_node)( const struct fs_info *info, void *node); enum fs_access_result (*look_up_file)( const struct fs_info *info, void **node_out, const char *path); enum fs_access_result (*stat_file)( const struct fs_info *info, void *node, struct fs_stat *stat_out); //start is in bytes. bounds-checking is caller responsibility. enum fs_access_result (*read_file)( const struct fs_info *info, void *node, void *buffer, uint64_t start, uint64_t bytes); }; enum fs_access_result create_fs_info( const struct drive_info *drive, struct fs_info *fs_out, const char *fs_type); void set_fs(const char *name, const struct fs_info *fs); //returns 0 if no fs is set with that name. const struct fs_info *get_fs(const char *name); enum fs_access_result look_up_file(const char *uri, const struct fs_info **fs_out, void **node_out);