This commit is contained in:
Baptiste Wicht 2016-08-17 18:31:15 +02:00
parent 802560a202
commit 02f08e109d

View File

@ -15,31 +15,138 @@
namespace vfs { namespace vfs {
/*!
* \brief Enumeration for all supported partition types
*/
enum class partition_type { enum class partition_type {
FAT32 = 1, FAT32 = 1, ///< FAT32
SYSFS = 2, SYSFS = 2, ///< Sysfs
DEVFS = 3, DEVFS = 3, ///< Devfs
PROCFS = 4, PROCFS = 4, ///< Procfs
UNKNOWN = 100 UNKNOWN = 100 ///< Unknown file system
}; };
/*!
* \brief Init the virtual file system
*/
void init(); 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); int64_t open(const char* file, size_t flags);
/*!
* \brief Close the given file descriptor
*/
void close(size_t fd); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); int64_t mount(partition_type type, const char* mount_point, const char* device);
/*! /*!