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" +};