fs: Added API to read mount point

Added API the read mount point names

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
Jan Van Winkel 2019-01-14 20:45:04 +01:00 committed by Anas Nashif
parent 430d9eddf4
commit 3815ae6f7f
2 changed files with 48 additions and 0 deletions

View file

@ -414,6 +414,22 @@ int fs_mount(struct fs_mount_t *mp);
*/
int fs_unmount(struct fs_mount_t *mp);
/**
* @brief Mount point read entry
*
* Read mount point entry
*
* @param number Pointer to mount point number
* @param name Pointer to mount point name
*
* @retval 0 Success
* @retval -ERRNO errno code if error
* @return On success \p number is incremented and \p name is set to mount
* point name. In case no mount point exists for the given \p number
* -ENOENT is returned and \p name is set to NULL.
*/
int fs_readmount(int *number, const char **name);
/**
* @brief File or directory status
*

View file

@ -515,6 +515,38 @@ unmount_err:
return rc;
}
int fs_readmount(int *number, const char **name)
{
sys_dnode_t *node;
int rc = -ENOENT;
int cnt = 0;
struct fs_mount_t *itr = NULL;
*name = NULL;
k_mutex_lock(&mutex, K_FOREVER);
SYS_DLIST_FOR_EACH_NODE(&fs_mnt_list, node) {
if (*number == cnt) {
itr = CONTAINER_OF(node, struct fs_mount_t, node);
break;
}
++cnt;
}
k_mutex_unlock(&mutex);
if (itr != NULL) {
rc = 0;
*name = itr->mnt_point;
++(*number);
}
return rc;
}
/* Register File system */
int fs_register(enum fs_type type, struct fs_file_system_t *fs)
{