Skip to content
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

sys/vfs: add vfs_unmount_by_path() #18109

Merged
merged 1 commit into from
May 17, 2022
Merged
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
12 changes: 12 additions & 0 deletions sys/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,18 @@ int vfs_mount(vfs_mount_t *mountp);
*/
int vfs_mount_by_path(const char *path);

/**
* @brief Unmount a file system with a pre-configured mount path
*
* @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_unmount_by_path(const char *path);

/**
* @brief Rename a file
*
Expand Down
11 changes: 11 additions & 0 deletions sys/vfs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,4 +1167,15 @@ int vfs_mount_by_path(const char *path)
return -ENOENT;
}

int vfs_unmount_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_umount(&vfs_mountpoints_xfa[i]);
}
}

return -ENOENT;
}

/** @} */