From 02f08e109d075d7a7b0d793862100b82393096c3 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Wed, 17 Aug 2016 18:31:15 +0200 Subject: [PATCH] Doc --- kernel/include/vfs/vfs.hpp | 117 +++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 5 deletions(-) diff --git a/kernel/include/vfs/vfs.hpp b/kernel/include/vfs/vfs.hpp index ed616b9b..48ae28f3 100644 --- a/kernel/include/vfs/vfs.hpp +++ b/kernel/include/vfs/vfs.hpp @@ -15,31 +15,138 @@ namespace vfs { +/*! + * \brief Enumeration for all supported partition types + */ enum class partition_type { - FAT32 = 1, - SYSFS = 2, - DEVFS = 3, - PROCFS = 4, - UNKNOWN = 100 + FAT32 = 1, ///< FAT32 + SYSFS = 2, ///< Sysfs + DEVFS = 3, ///< Devfs + PROCFS = 4, ///< Procfs + UNKNOWN = 100 ///< Unknown file system }; +/*! + * \brief Init the virtual file system + */ void init(); +/*! + * \brief Open the given file with the given flags + * \param file The path to the file to open + * \param flags The opening flags + * \return The file descriptor on success, a negative error code otherwise + */ int64_t open(const char* file, size_t flags); + +/*! + * \brief Close the given file descriptor + */ void close(size_t fd); +/*! + * \brief Returns information about the file represented by the fd + * \param fd The file descriptor + * \param info The info to fill + * \return a status code + */ int64_t stat(size_t fd, stat_info& info); + +/*! + * \brief Returns information about the file system + * \param mount_point The mount point + * \param info The info to fill + * \return a status code + */ int64_t statfs(const char* mount_point, statfs_info& info); + +/*! + * \brief Create a new directory + * \param file Path to the directory to create + * \return a status code + */ int64_t mkdir(const char* file); + +/*! + * \brief Remove a file + * \param file Path to the file to remove + * \return a status code + */ int64_t rm(const char* file); + +/*! + * \brief Read from a file + * \param fd The file descriptor to the file + * \param buffer The buffer to write to + * \param count The number of bytes to read + * \param offset The index where to start reading the file + * \return a status code + */ int64_t read(size_t fd, char* buffer, size_t count, size_t offset = 0); + +/*! + * \brief Write to a file + * \param fd The file descriptor to the file + * \param buffer The buffer to read from + * \param count The number of bytes to write + * \param offset The index where to start writting the file + * \return a status code + */ int64_t write(size_t fd, const char* buffer, size_t count, size_t offset = 0); + +/*! + * \brief Clear parts of a file content + * \param fd The file descriptor to the file + * \param count The number of bytes to write + * \param offset The index where to start writting the file + * \return a status code + */ int64_t clear(size_t fd, size_t count, size_t offset = 0); + +/*! + * \brief Truncate the size of a file + * \param fd The file descriptor + * \param size The new size + * \return a status code + */ int64_t truncate(size_t fd, size_t size); + +/*! + * \brief List entries in the given directory + * \param fd The file descriptor + * \param buffer The buffer to fill with the entries + * \param size The maximum size of the buffer + * \return a status code + */ int64_t entries(size_t fd, char* buffer, size_t size); + +/*! + * \brief List mounted file systems. + * \param buffer The buffer to fill with the entries + * \param size The maximum size of the buffer + * \return a status code + */ int64_t mounts(char* buffer, size_t size); +/*! + * \brief Mount a new partition + * \param type The type of partition + * \param mp_fd Mount point file descriptor + * \param dev_fd Device file descriptor + * \return a status code + */ int64_t mount(partition_type type, size_t mp_fd, size_t dev_fd); + +/*! + * \brief Mount a new partition + * + * This function is intended for direct mount from the OS code. + * + * \param type The type of partition + * \param mount_point Mount point path + * \param device Device path + * \return a status code + */ int64_t mount(partition_type type, const char* mount_point, const char* device); /*!