From 7293ea8928e1db5c9f7030df7854cd336ce73c97 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 2 Mar 2026 21:46:29 +0100 Subject: [PATCH] Add file_system driver --- .../include/tactility/drivers/file_system.h | 22 +++++++++++++++ .../source/drivers/file_system.cpp | 27 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 TactilityKernel/include/tactility/drivers/file_system.h create mode 100644 TactilityKernel/source/drivers/file_system.cpp diff --git a/TactilityKernel/include/tactility/drivers/file_system.h b/TactilityKernel/include/tactility/drivers/file_system.h new file mode 100644 index 00000000..f1d8dee1 --- /dev/null +++ b/TactilityKernel/include/tactility/drivers/file_system.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +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); diff --git a/TactilityKernel/source/drivers/file_system.cpp b/TactilityKernel/source/drivers/file_system.cpp new file mode 100644 index 00000000..09a9f8ac --- /dev/null +++ b/TactilityKernel/source/drivers/file_system.cpp @@ -0,0 +1,27 @@ +#include + +#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" +};