* 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 */
| 76 | * specified path |
| 77 | */ |
| 78 | struct 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. |
no test coverage detected