Skip to content
Permalink
Browse files

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>
  • Loading branch information...
vanwinkeljan authored and nashif committed Jan 14, 2019
1 parent 430d9ed commit 3815ae6f7fa4382aef8c387db179afa222793b14
Showing with 48 additions and 0 deletions.
  1. +16 −0 include/fs.h
  2. +32 −0 subsys/fs/fs.c
@@ -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
*
@@ -515,6 +515,38 @@ int fs_unmount(struct fs_mount_t *mp)
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)
{

0 comments on commit 3815ae6

Please sign in to comment.
You can’t perform that action at this time.