Luna/kernel/src/fs/FSRegistry.h

63 lines
2.3 KiB
C
Raw Normal View History

/**
* @file FSRegistry.h
* @author apio (cloudapio.eu)
* @brief Kernel registry of available file system implementations.
*
* @copyright Copyright (c) 2023, the Luna authors.
*
*/
#pragma once
#include "fs/VFS.h"
#include "fs/devices/Device.h"
typedef Result<SharedPtr<VFS::FileSystem>> (*VirtualFileSystemFactoryFunction)(void);
typedef Result<SharedPtr<VFS::FileSystem>> (*PhysicalFileSystemFactoryFunction)(SharedPtr<Device>);
namespace FSRegistry
{
/**
* @brief Register the built-in file system implementations.
*
* @return Result<void> Whether the operation succeeded.
*/
Result<void> init();
/**
* @brief Register a "virtual" (in-memory) file system implementation, associating a name to it.
*
* @param factory_function The factory function to use to create new instances of this file system.
* @param name The name to associate with this file system implementation.
* @return Result<void> Whether the operation succeeded.
*/
Result<void> register_virtual_filesystem(VirtualFileSystemFactoryFunction factory_function, StringView name);
/**
* @brief Register a "physical" (mounted from a device) file system implementation, associating a name
* to it.
*
* @param factory_function The factory function to use to create new instances of this file system.
* @param name The name to associate with this file system implementation.
* @return Result<void> Whether the operation succeeded.
*/
Result<void> register_physical_filesystem(PhysicalFileSystemFactoryFunction factory_function, StringView name);
/**
* @brief Find a "virtual" (in-memory) file system implementation by name.
*
* @param name The name to look for.
* @return Result<VirtualFileSystemFactoryFunction> An error, or the factory function to create file systems of this
* type.
*/
Result<VirtualFileSystemFactoryFunction> lookup_virtual_filesystem(StringView name);
/**
* @brief Find a "physical" (mounted from a device) file system implementation by name.
*
* @param name The name to look for.
* @return Result<PhysicalFileSystemFactoryFunction> An error, or the factory function to create file systems of
* this type.
*/
Result<PhysicalFileSystemFactoryFunction> lookup_physical_filesystem(StringView name);
}