MCPcopy Create free account
hub / github.com/apache/nuttx / rpmsgfs_mkpath

Function rpmsgfs_mkpath

fs/rpmsgfs/rpmsgfs.c:206–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204 ****************************************************************************/
205
206static void rpmsgfs_mkpath(FAR struct rpmsgfs_mountpt_s *fs,
207 FAR const char *relpath,
208 FAR char *path, int pathlen)
209{
210 int depth = 0;
211 int first;
212 int x;
213
214 /* Copy base host path to output */
215
216 strlcpy(path, fs->fs_root, pathlen);
217
218 /* Be sure we aren't trying to use ".." to display outside of our
219 * mounted path.
220 */
221
222 x = 0;
223 while (relpath[x] == '/')
224 {
225 x++;
226 }
227
228 first = x;
229
230 while (relpath[x] != '\0')
231 {
232 /* Test for ".." occurrence */
233
234 if (strncmp(&relpath[x], "..", 2) == 0)
235 {
236 /* Reduce depth by 1 */
237
238 depth--;
239 x += 2;
240 }
241
242 else if (relpath[x] == '/' && relpath[x + 1] != '/' &&
243 relpath[x + 1] != '\0')
244 {
245 depth++;
246 x++;
247 }
248 else
249 {
250 x++;
251 }
252 }
253
254 if (depth >= 0)
255 {
256 strlcat(path, &relpath[first], pathlen - strlen(path));
257 }
258
259 while (fs->timeout > 0)
260 {
261 struct stat buf;
262 int ret;
263

Callers 7

rpmsgfs_openFunction · 0.85
rpmsgfs_opendirFunction · 0.85
rpmsgfs_unlinkFunction · 0.85
rpmsgfs_mkdirFunction · 0.85
rpmsgfs_rmdirFunction · 0.85
rpmsgfs_statFunction · 0.85
rpmsgfs_chstatFunction · 0.85

Calls 6

rpmsgfs_client_statFunction · 0.85
nxsched_usleepFunction · 0.85
strlcpyFunction · 0.50
strncmpFunction · 0.50
strlcatFunction · 0.50
strlenFunction · 0.50

Tested by

no test coverage detected