Add file_system driver

This commit is contained in:
Ken Van Hoeylandt 2026-03-02 21:46:29 +01:00
parent 880bae3fae
commit 7293ea8928
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#pragma once
#include <tactility/error.h>
struct Device;
struct FileSystemApi {
error_t (*mount)(struct Device* device);
error_t (*unmount)(struct Device* device);
bool (*is_mounted)(struct Device* device);
error_t (*get_mount_path)(struct Device*, char* out_path);
};
extern const struct DeviceType FILE_SYSTEM_TYPE;
error_t file_system_mount(struct Device* device);
error_t file_system_unmount(struct Device* device);
bool file_system_is_mounted(struct Device* device);
error_t file_system_get_mount_path(struct Device*, char* out_path);

View File

@ -0,0 +1,27 @@
#include <tactility/drivers/file_system.h>
#define INTERNAL_API(driver) ((struct FileSystem*)(driver)->api)
error_t file_system_mount(struct Device* device) {
const auto* driver = device_get_driver(device);
return INTERNAL_API(driver)->mount(device);
}
error_t file_system_unmount(struct Device* device) {
const auto* driver = device_get_driver(device);
return INTERNAL_API(driver)->unmount(device);
}
bool file_system_is_mounted(struct Device* device) {
const auto* driver = device_get_driver(device);
return INTERNAL_API(driver)->is_mounted(device);
}
error_t file_system_get_mount_path(struct Device*, char* out_path) {
const auto* driver = device_get_driver(device);
return INTERNAL_API(driver)->get_mount_path(device, out_path);
}
const struct DeviceType FILE_SYSTEM_TYPE {
.name = "file-system"
};