1 /*
2 * Copyright (c) 2006-2024, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 */
9
10 #ifndef __DFS_VFS_H__
11 #define __DFS_VFS_H__
12
13 #include "dfs_file.h"
14 #include "dfs_fs.h"
15
16 #ifdef __cplusplus
17 extern "C"
18 {
19 #endif
20
21 struct dfs_vfs_node
22 {
23 rt_list_t subnode; /* file subnode list */
24 rt_list_t sibling; /* file sibling list */
25 };
26
dfs_vfs_init_node(struct dfs_vfs_node * node)27 rt_inline void dfs_vfs_init_node(struct dfs_vfs_node *node)
28 {
29 rt_list_init(&node->subnode);
30 rt_list_init(&node->sibling);
31 }
32
dfs_vfs_append_node(struct dfs_vfs_node * dir,struct dfs_vfs_node * node)33 rt_inline void dfs_vfs_append_node(struct dfs_vfs_node *dir, struct dfs_vfs_node *node)
34 {
35 rt_list_insert_after(&(dir->subnode), &(node->sibling));
36 }
37
dfs_vfs_remove_node(struct dfs_vfs_node * node)38 rt_inline void dfs_vfs_remove_node(struct dfs_vfs_node *node)
39 {
40 rt_list_remove(&(node->sibling));
41 }
42
43 #define dfs_vfs_for_each_subnode(node, tmp, dir, member) \
44 rt_list_for_each_entry_safe(node, tmp, &dir->member.subnode, member.sibling)
45
46 #ifdef __cplusplus
47 }
48 #endif
49
50 #endif /*__DFS_VFS_H__*/
51