From a118801bfeefb8579255f04f8fcab540a2f0deba Mon Sep 17 00:00:00 2001 From: bernard Date: Thu, 26 Jun 2014 13:59:26 +0800 Subject: [PATCH] [DFS] Add dfs_filesystem_get_mounted_path() function. --- components/dfs/include/dfs_fs.h | 2 ++ components/dfs/src/dfs_fs.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h index 3fa999c34..498aa5db5 100644 --- a/components/dfs/include/dfs_fs.h +++ b/components/dfs/include/dfs_fs.h @@ -94,6 +94,8 @@ struct dfs_mount_tbl int dfs_register(const struct dfs_filesystem_operation *ops); struct dfs_filesystem *dfs_filesystem_lookup(const char *path); +const char* dfs_filesystem_get_mounted_path(struct rt_device* device); + rt_err_t dfs_filesystem_get_partition(struct dfs_partition *part, rt_uint8_t *buf, rt_uint32_t pindex); diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index a41f36cf0..bdd9560d5 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -115,6 +115,37 @@ struct dfs_filesystem *dfs_filesystem_lookup(const char *path) return fs; } +/** + * this function will return the mounted path for specified device. + * + * @param device the device object which is mounted. + * + * @return the mounted path or RT_NULL if none device mounted. + */ +const char* dfs_filesystem_get_mounted_path(struct rt_device* device) +{ + const char* path = RT_NULL; + struct dfs_filesystem *iter; + + dfs_lock(); + for (iter = &filesystem_table[0]; + iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) + { + /* fint the mounted device */ + if (iter->ops == RT_NULL) continue; + else if (iter->dev_id == device) + { + path = iter->path; + break; + } + } + + /* release filesystem_table lock */ + dfs_unlock(); + + return path; +} + /** * this function will fetch the partition table on specified buffer. * -- GitLab