1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

vfs: introduce vfs_format_by_path()

This commit is contained in:
Benjamin Valentin 2022-08-11 16:29:35 +02:00
parent 7f5c932f07
commit 855a359058
2 changed files with 26 additions and 0 deletions

View File

@ -898,6 +898,21 @@ int vfs_closedir(vfs_DIR *dirp);
*/
int vfs_format(vfs_mount_t *mountp);
/**
* @brief Format a file system
*
* The file system must not be mounted in order to be formatted.
* Call @ref vfs_unmount_by_path first if necessary.
*
* @note This assumes mount points have been configured with @ref VFS_AUTO_MOUNT.
*
* @param[in] path Path of the pre-configured mount point
*
* @return 0 on success
* @return <0 on error
*/
int vfs_format_by_path(const char *path);
/**
* @brief Mount a file system
*

View File

@ -1208,4 +1208,15 @@ int vfs_unmount_by_path(const char *path)
return -ENOENT;
}
int vfs_format_by_path(const char *path)
{
for (unsigned i = 0; i < MOUNTPOINTS_NUMOF; ++i) {
if (strcmp(path, vfs_mountpoints_xfa[i].mount_point) == 0) {
return vfs_format(&vfs_mountpoints_xfa[i]);
}
}
return -ENOENT;
}
/** @} */