lib: fs: implement mounting filesystems; reading, writing from files

This commit is contained in:
2026-03-10 19:15:26 +00:00
parent aef0163017
commit 6d88cf4bf3
14 changed files with 393 additions and 41 deletions

View File

@@ -2,30 +2,54 @@
#define FS_CONTEXT_H_
#include <rosetta/fs.h>
#include <xpc/msg.h>
struct fs_file;
struct fs_dentry;
struct fs_context;
struct fs_allocator;
struct fs_superblock;
extern struct fs_context *fs_context_create(
struct fs_allocator *alloc,
struct fs_superblock *sb);
enum fs_mount_flags {
FS_MOUNT_READONLY = 0x01u,
};
typedef enum fs_status (*fs_mount_function_t)(
struct fs_context *,
void *arg,
enum fs_mount_flags,
struct fs_superblock **);
extern struct fs_context *fs_context_create(struct fs_allocator *alloc);
extern void fs_context_destroy(struct fs_context *ctx);
extern enum fs_status fs_context_mount_filesystem(
struct fs_context *ctx,
fs_mount_function_t func,
void *arg,
enum fs_mount_flags flags);
extern enum fs_status fs_context_unmount_filesystem(struct fs_context *ctx);
extern struct fs_file *fs_context_open_file(
struct fs_context *ctx,
unsigned long id);
extern struct fs_file *fs_context_get_file(
struct fs_context *ctx,
unsigned long id);
extern void fs_context_close_file(struct fs_context *ctx, struct fs_file *f);
extern struct fs_dentry *fs_context_resolve_path(
extern enum fs_status fs_context_resolve_path(
struct fs_context *ctx,
const char *path);
const char *path,
struct fs_dentry **out);
extern kern_status_t fs_context_dispatch_msg(
struct fs_context *ctx,
kern_handle_t channel,
struct msg_endpoint *sender,
struct msg_header *hdr);
xpc_msg_t *msg);
extern void *fs_context_alloc(struct fs_context *ctx, size_t count);
extern void *fs_context_calloc(struct fs_context *ctx, size_t count, size_t sz);
extern void *fs_context_realloc(struct fs_context *ctx, void *p, size_t count);
extern void fs_context_free(struct fs_context *ctx, void *p);
#endif