Skip to content

Standardized FileSystem init/deinit/reset to match KVStore API #8700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions features/storage/filesystem/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ FileSystem::FileSystem(const char *name)
{
}

int FileSystem::init()
{
return 0;
}

int FileSystem::deinit()
{
return 0;
}

int FileSystem::mount(BlockDevice *bd)
{
return -ENOSYS;
}

int FileSystem::unmount()
{
return -ENOSYS;
}

int FileSystem::reset()
{
return -ENOSYS;
}

int FileSystem::reformat(BlockDevice *bd)
{
return -ENOSYS;
Expand Down
32 changes: 30 additions & 2 deletions features/storage/filesystem/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,44 @@ class FileSystem : public FileSystemLike {
*/
static FileSystem *get_default_instance();

/** Initializes the file system
*
* The init function may be called multiple times recursively as long
* as each init has a matching deinit. If not called, the file system
* will be mounted on the first file system operation.
*
* @return 0 on success, negative error code on failure
*/
virtual int init();

/** Deinitializes the file system
*
* @return 0 on success, negative error code on failure
*/
virtual int deinit();

/** Reformats the underlying filesystem

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify explicitly that file system will be initialised and mounted as part of reset call?

*
* @return 0 on success, negative error code on failure
*/
virtual int reset();

/** Mounts a filesystem to a block device
*
* @param bd BlockDevice to mount to
* @return 0 on success, negative error code on failure
* @deprecated Replaced by FileSystem::init for consistency with other storage APIs
*/
virtual int mount(BlockDevice *bd) = 0;
MBED_DEPRECATED_SINCE("mbed-os-5.11", "Replaced by FileSystem::init for consistency with other storage APIs")
virtual int mount(BlockDevice *bd);

/** Unmounts a filesystem from the underlying block device
*
* @return 0 on success, negative error code on failure
* @deprecated Replaced by FileSystem::deinit for consistency with other storage APIs
*/
virtual int unmount() = 0;
MBED_DEPRECATED_SINCE("mbed-os-5.11", "Replaced by FileSystem::deinit for consistency with other storage APIs")
virtual int unmount();

/** Reformats a filesystem, results in an empty and mounted filesystem
*
Expand All @@ -91,7 +117,9 @@ class FileSystem : public FileSystemLike {
* Note: if mount fails, bd must be provided.
* Default: NULL
* @return 0 on success, negative error code on failure
* @deprecated Replaced by FileSystem::reset for consistency with other storage APIs
*/
MBED_DEPRECATED_SINCE("mbed-os-5.11", "Replaced by FileSystem::reset for consistency with other storage APIs")
virtual int reformat(BlockDevice *bd = NULL);

/** Remove a file from the filesystem.
Expand Down
Loading