Path: blob/master/libraries/AP_Filesystem/AP_Filesystem_FATFS.h
9447 views
/*1FATFS backend for AP_Filesystem2*/34#pragma once56#include <sys/types.h>7#include <sys/stat.h>8#include <fcntl.h>9#include <errno.h>10#include <stddef.h>11#include "AP_Filesystem_backend.h"1213#if AP_FILESYSTEM_FATFS_ENABLED1415// Seek offset macros16#define SEEK_SET 017#define SEEK_CUR 118#define SEEK_END 21920class AP_Filesystem_FATFS : public AP_Filesystem_Backend21{22public:23// functions that closely match the equivalent posix calls24int open(const char *fname, int flags, bool allow_absolute_paths = false) override;25int close(int fd) override;26int32_t read(int fd, void *buf, uint32_t count) override;27int32_t write(int fd, const void *buf, uint32_t count) override;28int fsync(int fd) override;29int32_t lseek(int fd, int32_t offset, int whence) override;30int stat(const char *pathname, struct stat *stbuf) override;31int unlink(const char *pathname) override;32int mkdir(const char *pathname) override;33void *opendir(const char *pathname) override;34int rename(const char *oldpath, const char *newpath) override;35struct dirent *readdir(void *dirp) override;36int closedir(void *dirp) override;3738uint32_t bytes_until_fsync(int fd) override;3940// return free disk space in bytes, -1 on error41int64_t disk_free(const char *path) override;4243// return total disk space in bytes, -1 on error44int64_t disk_space(const char *path) override;4546// set modification time on a file47bool set_mtime(const char *filename, const uint32_t mtime_sec) override;4849// retry mount of filesystem if needed50bool retry_mount(void) override;5152// unmount filesystem for reboot53void unmount(void) override;5455// format sdcard. This is async, monitor get_format_status for progress56bool format(void) override;57AP_Filesystem_Backend::FormatStatus get_format_status() const override;5859static void set_io_size(uint32_t _io_size) { io_size = _io_size; }60static uint32_t get_io_size() { return io_size; }6162private:63static uint32_t io_size;64void format_handler(void);65FormatStatus format_status;66};6768#endif // #if AP_FILESYSTEM_FATFS_ENABLED697071