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

Function _dfs_mnt_foreach

components/dfs/dfs_v2/src/dfs_mnt.c:458–487  ·  view source on GitHub ↗

* @brief Recursively traverse the mount point tree and apply a callback function. * * This function performs a depth-first traversal of the mount point tree starting from the given mount point. * It applies the specified callback function to each mount point in the tree. If the callback function returns * a non-NULL pointer, the traversal stops and the result is returned immediately. * * @pa

Source from the content-addressed store, hash-verified

456 * Otherwise, returns RT_NULL.
457 */
458static struct dfs_mnt* _dfs_mnt_foreach(struct dfs_mnt *mnt, struct dfs_mnt* (*func)(struct dfs_mnt *mnt, void *parameter), void *parameter)
459{
460 struct dfs_mnt *iter, *ret = NULL;
461
462 if (mnt)
463 {
464 ret = func(mnt, parameter);
465 if (ret == RT_NULL)
466 {
467 if (!rt_list_isempty(&mnt->child))
468 {
469 /* for each in mount point list */
470 rt_list_for_each_entry(iter, &mnt->child, sibling)
471 {
472 ret = _dfs_mnt_foreach(iter, func, parameter);
473 if (ret != RT_NULL)
474 {
475 break;
476 }
477 }
478 }
479 }
480 }
481 else
482 {
483 ret = RT_NULL;
484 }
485
486 return ret;
487}
488
489/**
490 * @brief Compare a mount point's device ID with a given device object.

Callers 4

dfs_mnt_get_mounted_pathFunction · 0.85
dfs_mnt_has_child_mntFunction · 0.85
dfs_mnt_listFunction · 0.85
dfs_mnt_foreachFunction · 0.85

Calls 1

rt_list_isemptyFunction · 0.85

Tested by

no test coverage detected