117 lines
4.3 KiB
C
117 lines
4.3 KiB
C
#ifndef FS_MGMT_H
|
|
#define FS_MGMT_H
|
|
|
|
#include <zephyr/fs/fs.h>
|
|
|
|
#define FS_MGMT_MAX_PATH_LENGTH 32
|
|
#define FS_AUDIO_PATH CONFIG_FS_MGMT_MOUNT_POINT "/a"
|
|
#define FS_SYSTEM_PATH CONFIG_FS_MGMT_MOUNT_POINT "/sys"
|
|
|
|
/**
|
|
* @brief Initializes the filesystem management module.
|
|
*/
|
|
int fs_mgmt_init(void);
|
|
|
|
// /**
|
|
// * @brief Puts the QSPI flash into deep sleep mode to save power
|
|
// */
|
|
// int fs_pm_flash_suspend(void);
|
|
|
|
// /**
|
|
// * @brief Resumes the QSPI flash from deep sleep mode
|
|
// */
|
|
// int fs_pm_flash_resume(void);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_open that handles power management for the flash
|
|
* Resumes the flash before opening and suspends it if opening fails
|
|
* @param file Pointer to fs_file_t structure to be initialized
|
|
* @param path Path to the file to open
|
|
* @param mode Open flags (e.g. FS_O_READ, FS_O_WRITE)
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_open(struct fs_file_t *file, const char *path, fs_mode_t mode);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_close that handles power management for the flash
|
|
* Resumes the flash after closing and suspends it if closing fails
|
|
* @param file Pointer to fs_file_t structure to be closed
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_close(struct fs_file_t *file);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_opendir that handles power management for the flash
|
|
* Resumes the flash before opening and suspends it if opening fails
|
|
* @param dirp Pointer to fs_dir_t structure to be initialized
|
|
* @param path Path to the directory to open
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_opendir(struct fs_dir_t *dirp, const char *path);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_closedir that handles power management for the flash
|
|
* Resumes the flash after closing and suspends it if closing fails
|
|
* @param dirp Pointer to fs_dir_t structure to be closed
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_closedir(struct fs_dir_t *dirp);
|
|
|
|
/**
|
|
* @brief Unlinks (deletes) a file, ensuring the flash is active during the operation
|
|
* @param path Path to the file to unlink
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_unlink(const char *path);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_statvfs that handles power management for the flash
|
|
* Resumes the flash before getting stats and suspends it afterwards
|
|
* @param path Path to the filesystem to get stats for
|
|
* @param stat Pointer to fs_statvfs structure to be filled with stats
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_statvfs(const char *path, struct fs_statvfs *stat);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_stat that handles power management for the flash
|
|
* Resumes the flash before stat and suspends it afterwards
|
|
* @param path Path to file or directory
|
|
* @param entry Pointer to fs_dirent structure to receive metadata
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_stat(const char *path, struct fs_dirent *entry);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_mkdir that handles power management for the flash
|
|
* Resumes the flash before creating the directory and suspends it afterwards
|
|
* @param path Path to the directory to create
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_mkdir(const char *path);
|
|
|
|
/**
|
|
* @brief Wrapper around fs_rename that handles power management for the flash
|
|
* Resumes the flash before renaming and suspends it afterwards
|
|
* @param old_path Current path of the file or directory
|
|
* @param new_path New path for the file or directory
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_rename(const char *old_path, const char *new_path);
|
|
|
|
/**
|
|
* @brief Recursively creates directories for the given path, ensuring the flash is active during the operation
|
|
* @param path Path to the directory to create (can include multiple levels, e.g. "/dir1/dir2/dir3")
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_mkdir_recursive(char *path);
|
|
|
|
/**
|
|
* @brief Recursively removes a directory and all its contents, ensuring the flash is active during the operation
|
|
* @param path Path to the directory to remove
|
|
* @param max_len Maximum length of the path buffer
|
|
* @return 0 on success, negative error code on failure
|
|
*/
|
|
int fs_mgmt_pm_rm_recursive(char *path, size_t max_len);
|
|
|
|
#endif /* FS_MGMT_H */ |