AP_Filesystem: replace HAVE_FILESYSTEM_SUPPORT with backend defines

This commit is contained in:
Peter Barker 2023-05-15 11:44:22 +10:00 committed by Peter Barker
parent 189712830c
commit 1c54d18672
9 changed files with 66 additions and 35 deletions

View File

@ -20,24 +20,19 @@
static AP_Filesystem fs;
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#if HAVE_FILESYSTEM_SUPPORT
// create exactly one "local" filesystem:
#if AP_FILESYSTEM_FATFS_ENABLED
#include "AP_Filesystem_FATFS.h"
static AP_Filesystem_FATFS fs_local;
#elif AP_FILESYSTEM_ESP32_ENABLED
#include "AP_Filesystem_ESP32.h"
static AP_Filesystem_ESP32 fs_local;
#elif AP_FILESYSTEM_POSIX_ENABLED
#include "AP_Filesystem_posix.h"
static AP_Filesystem_Posix fs_local;
#else
static AP_Filesystem_Backend fs_local;
int errno;
#endif // HAVE_FILESYSTEM_SUPPORT
#endif // HAL_BOARD_CHIBIOS
#if CONFIG_HAL_BOARD == HAL_BOARD_ESP32
#include "AP_Filesystem_ESP32.h"
static AP_Filesystem_ESP32 fs_local;
#endif // HAL_BOARD_ESP32
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX || CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_Filesystem_posix.h"
static AP_Filesystem_Posix fs_local;
#endif
#if AP_FILESYSTEM_ROMFS_ENABLED

View File

@ -35,7 +35,7 @@
#endif
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#if HAVE_FILESYSTEM_SUPPORT
#if AP_FILESYSTEM_FATFS_ENABLED
#include "AP_Filesystem_FATFS.h"
#endif

View File

@ -17,8 +17,7 @@
#include "AP_Filesystem.h"
#include <AP_HAL/AP_HAL.h>
#if HAVE_FILESYSTEM_SUPPORT
#if CONFIG_HAL_BOARD == HAL_BOARD_ESP32
#if AP_FILESYSTEM_ESP32_ENABLED
#define FSDEBUG 0
@ -199,5 +198,4 @@ bool AP_Filesystem_ESP32::set_mtime(const char *filename, const uint32_t mtime_s
return utime(filename, &times) == 0;
}
#endif // CONFIG_HAL_BOARD
#endif
#endif // AP_FILESYSTEM_ESP32_ENABLED

View File

@ -1,14 +1,16 @@
/*
ArduPilot filesystem interface for systems using the FATFS filesystem
*/
#include "AP_Filesystem_config.h"
#if AP_FILESYSTEM_FATFS_ENABLED
#include "AP_Filesystem.h"
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.h>
#include <stdio.h>
#include <AP_RTC/AP_RTC.h>
#if HAVE_FILESYSTEM_SUPPORT && CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#include <ff.h>
#include <AP_HAL_ChibiOS/sdcard.h>
#include <GCS_MAVLink/GCS.h>
@ -975,4 +977,4 @@ char *strerror(int errnum)
return NULL;
}
#endif // CONFIG_HAL_BOARD
#endif // AP_FILESYSTEM_FATFS_ENABLED

View File

@ -11,6 +11,8 @@
#include <stddef.h>
#include "AP_Filesystem_backend.h"
#if AP_FILESYSTEM_FATFS_ENABLED
// Seek offset macros
#define SEEK_SET 0
#define SEEK_CUR 1
@ -57,3 +59,5 @@ private:
void format_handler(void);
FormatStatus format_status;
};
#endif // #if AP_FILESYSTEM_FATFS_ENABLED

View File

@ -4,24 +4,49 @@
#include <AP_Mission/AP_Mission_config.h>
#if HAL_OS_POSIX_IO || HAL_OS_FATFS_IO
#define HAVE_FILESYSTEM_SUPPORT 1
#else
#define HAVE_FILESYSTEM_SUPPORT 0
// backends:
#ifndef AP_FILESYSTEM_ESP32_ENABLED
#define AP_FILESYSTEM_ESP32_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_ESP32)
#endif
#ifndef AP_FILESYSTEM_PARAM_ENABLED
#define AP_FILESYSTEM_PARAM_ENABLED 1
#ifndef AP_FILESYSTEM_FATFS_ENABLED
#define AP_FILESYSTEM_FATFS_ENABLED HAL_OS_FATFS_IO
#endif
#ifndef AP_FILESYSTEM_MISSION_ENABLED
#define AP_FILESYSTEM_MISSION_ENABLED AP_MISSION_ENABLED
#endif
#ifndef AP_FILESYSTEM_SYS_ENABLED
#define AP_FILESYSTEM_SYS_ENABLED 1
#ifndef AP_FILESYSTEM_PARAM_ENABLED
#define AP_FILESYSTEM_PARAM_ENABLED 1
#endif
#ifndef AP_FILESYSTEM_POSIX_ENABLED
#define AP_FILESYSTEM_POSIX_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX)
#endif
#ifndef AP_FILESYSTEM_ROMFS_ENABLED
#define AP_FILESYSTEM_ROMFS_ENABLED defined(HAL_HAVE_AP_ROMFS_EMBEDDED_H)
#endif
#ifndef AP_FILESYSTEM_SYS_ENABLED
#define AP_FILESYSTEM_SYS_ENABLED 1
#endif
// AP_FILESYSTEM_FILE_READING_ENABLED is true if you could expect to
// be able to open and write a non-virtual file. Notably this
// excludes virtual files like SYSFS, and the magic param/mission
// upload targets, and also excludes ROMFS (where you can read but not
// write!)
#ifndef AP_FILESYSTEM_FILE_WRITING_ENABLED
#define AP_FILESYSTEM_FILE_WRITING_ENABLED (AP_FILESYSTEM_ESP32_ENABLED || AP_FILESYSTEM_FATFS_ENABLED || AP_FILESYSTEM_POSIX_ENABLED)
#endif
// AP_FILESYSTEM_FILE_READING_ENABLED is true if you could expect to
// be able to open and read a non-virtual file. Notably this excludes
// virtual files like SYSFS, and the magic param/mission upload targets.
#ifndef AP_FILESYSTEM_FILE_READING_ENABLED
#define AP_FILESYSTEM_FILE_READING_ENABLED (AP_FILESYSTEM_FILE_WRITING_ENABLED || AP_FILESYSTEM_ROMFS_ENABLED)
#endif

View File

@ -15,12 +15,15 @@
/*
ArduPilot filesystem interface for posix systems
*/
#include "AP_Filesystem_config.h"
#if AP_FILESYSTEM_POSIX_ENABLED
#include "AP_Filesystem.h"
#include <AP_HAL/AP_HAL.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#if defined(__APPLE__)
#include <sys/mount.h>
#else
@ -182,5 +185,4 @@ bool AP_Filesystem_Posix::set_mtime(const char *filename, const uint32_t mtime_s
return utime(filename, &times) == 0;
}
#endif // CONFIG_HAL_BOARD
#endif // AP_FILESYSTEM_POSIX_ENABLED

View File

@ -15,6 +15,10 @@
#pragma once
#include "AP_Filesystem_config.h"
#if AP_FILESYSTEM_POSIX_ENABLED
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -53,3 +57,4 @@ public:
bool set_mtime(const char *filename, const uint32_t mtime_sec) override;
};
#endif // AP_FILESYSTEM_POSIX_ENABLED

View File

@ -24,7 +24,7 @@
#include "AP_Filesystem.h"
#if HAVE_FILESYSTEM_SUPPORT
#if AP_FILESYSTEM_FATFS_ENABLED || AP_FILESYSTEM_POSIX_ENABLED || AP_FILESYSTEM_ESP32_ENABLED
#include "posix_compat.h"
#include <stdarg.h>
@ -268,4 +268,4 @@ int apfs_remove(const char *pathname)
return AP::FS().unlink(pathname);
}
#endif // HAVE_FILESYSTEM_SUPPORT
#endif // AP_FILESYSTEM_POSIX_ENABLED