MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_filesystem_lookup

Function dfs_filesystem_lookup

components/dfs/dfs_v1/src/dfs_fs.c:78–114  ·  view source on GitHub ↗

* this function will return the file system mounted on specified path. * * @param path the specified path string. * * @return the found file system or NULL if no file system mounted on * specified path */

Source from the content-addressed store, hash-verified

76 * specified path
77 */
78struct dfs_filesystem *dfs_filesystem_lookup(const char *path)
79{
80 struct dfs_filesystem *iter;
81 struct dfs_filesystem *fs = NULL;
82 uint32_t fspath, prefixlen;
83
84 prefixlen = 0;
85
86 RT_ASSERT(path);
87
88 /* lock filesystem */
89 dfs_lock();
90
91 /* lookup it in the filesystem table */
92 for (iter = &filesystem_table[0];
93 iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++)
94 {
95 if ((iter->path == NULL) || (iter->ops == NULL))
96 continue;
97
98 fspath = strlen(iter->path);
99 if ((fspath < prefixlen)
100 || (strncmp(iter->path, path, fspath) != 0))
101 continue;
102
103 /* check next path separator */
104 if (fspath > 1 && (strlen(path) > fspath) && (path[fspath] != '/'))
105 continue;
106
107 fs = iter;
108 prefixlen = fspath;
109 }
110
111 dfs_unlock();
112
113 return fs;
114}
115
116/**
117 * this function will return the mounted path for specified device.

Callers 15

dfs_tmpfs_statFunction · 0.85
dfs_device_fs_statFunction · 0.85
fd_is_openFunction · 0.85
dfs_file_openFunction · 0.85
dfs_file_unlinkFunction · 0.85
dfs_file_statFunction · 0.85
dfs_file_renameFunction · 0.85
dfs_statfsFunction · 0.85

Calls 2

dfs_lockFunction · 0.70
dfs_unlockFunction · 0.70

Tested by

no test coverage detected