summaryrefslogtreecommitdiff
path: root/components/dfs/dfs_v2/include/dfs_vfs.h
blob: 36741920441f56de548cbc47795b1b9c01559806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright (c) 2006-2024, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 */

#ifndef __DFS_VFS_H__
#define __DFS_VFS_H__

#include "dfs_file.h"
#include "dfs_fs.h"

#ifdef __cplusplus
extern "C"
{
#endif

struct dfs_vfs_node
{
    rt_list_t     subnode;     /* file subnode list */
    rt_list_t     sibling;     /* file sibling list */
};

rt_inline void dfs_vfs_init_node(struct dfs_vfs_node *node)
{
    rt_list_init(&node->subnode);
    rt_list_init(&node->sibling);
}

rt_inline void dfs_vfs_append_node(struct dfs_vfs_node *dir, struct dfs_vfs_node *node)
{
    rt_list_insert_after(&(dir->subnode), &(node->sibling));
}

rt_inline void dfs_vfs_remove_node(struct dfs_vfs_node *node)
{
    rt_list_remove(&(node->sibling));
}

#define dfs_vfs_for_each_subnode(node, tmp, dir, member)                          \
    rt_list_for_each_entry_safe(node, tmp, &dir->member.subnode, member.sibling)

#ifdef __cplusplus
}
#endif

#endif /*__DFS_VFS_H__*/