summaryrefslogtreecommitdiff
path: root/components/dfs/dfs_v2/include/dfs_dentry.h
blob: 190e277b0bf2a777b950bffa5d284f1d28595692 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-05-05     Bernard      Implement dentry in dfs v2.0
 */

#ifndef __DFS_DENTRY_H__
#define __DFS_DENTRY_H__

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

#ifdef __cplusplus
extern "C"
{
#endif

struct dfs_mnt;
struct dfs_vnode;

struct dfs_dentry
{
    rt_list_t hashlist;

    uint32_t flags;

#define DENTRY_IS_MOUNTED   0x1 /* dentry is mounted */
#define DENTRY_IS_ALLOCED   0x2 /* dentry is allocated */
#define DENTRY_IS_ADDHASH   0x4 /* dentry was added into hash table */
#define DENTRY_IS_OPENED    0x8 /* dentry was opened. */
    char *pathname;             /* the pathname under mounted file sytem */

    struct dfs_vnode *vnode;    /* the vnode of this dentry */
    struct dfs_mnt *mnt;        /* which mounted file system does this dentry belong to */

    rt_atomic_t ref_count;    /* the reference count */
};

struct dfs_dentry *dfs_dentry_create(struct dfs_mnt *mnt, char *fullpath);
struct dfs_dentry *dfs_dentry_unref(struct dfs_dentry *dentry);
struct dfs_dentry *dfs_dentry_ref(struct dfs_dentry *dentry);
void dfs_dentry_insert(struct dfs_dentry *dentry);
struct dfs_dentry *dfs_dentry_lookup(struct dfs_mnt *mnt, const char *path, uint32_t flags);

/* get full path of a dentry */
char* dfs_dentry_full_path(struct dfs_dentry* dentry);

/* get pathname (with mnt path) of a dentry */
char* dfs_dentry_pathname(struct dfs_dentry* dentry);

/* get full path crc32 */
uint32_t dfs_dentry_full_path_crc32(struct dfs_dentry* dentry);

int dfs_dentry_init(void);

#ifdef __cplusplus
}
#endif

#endif /*__DFS_DENTRY_H__*/