1 /* 2 * Copyright (c) 2006-2023, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2023-05-05 Bernard Implement dentry in dfs v2.0 9 */ 10 11 #ifndef __DFS_DENTRY_H__ 12 #define __DFS_DENTRY_H__ 13 14 #include "dfs_file.h" 15 #include "dfs_fs.h" 16 17 #ifdef __cplusplus 18 extern "C" 19 { 20 #endif 21 22 struct dfs_mnt; 23 struct dfs_vnode; 24 25 struct dfs_dentry 26 { 27 rt_list_t hashlist; 28 29 uint32_t flags; 30 31 #define DENTRY_IS_MOUNTED 0x1 /* dentry is mounted */ 32 #define DENTRY_IS_ALLOCED 0x2 /* dentry is allocated */ 33 #define DENTRY_IS_ADDHASH 0x4 /* dentry was added into hash table */ 34 #define DENTRY_IS_OPENED 0x8 /* dentry was opened. */ 35 char *pathname; /* the pathname under mounted file sytem */ 36 37 struct dfs_vnode *vnode; /* the vnode of this dentry */ 38 struct dfs_mnt *mnt; /* which mounted file system does this dentry belong to */ 39 40 rt_atomic_t ref_count; /* the reference count */ 41 }; 42 43 struct dfs_dentry *dfs_dentry_create(struct dfs_mnt *mnt, char *fullpath); 44 struct dfs_dentry *dfs_dentry_create_rela(struct dfs_mnt *mnt, char *rela_path); 45 struct dfs_dentry *dfs_dentry_unref(struct dfs_dentry *dentry); 46 struct dfs_dentry *dfs_dentry_ref(struct dfs_dentry *dentry); 47 void dfs_dentry_insert(struct dfs_dentry *dentry); 48 struct dfs_dentry *dfs_dentry_lookup(struct dfs_mnt *mnt, const char *path, uint32_t flags); 49 50 /* get full path of a dentry */ 51 char* dfs_dentry_full_path(struct dfs_dentry* dentry); 52 53 /* get pathname (with mnt path) of a dentry */ 54 char* dfs_dentry_pathname(struct dfs_dentry* dentry); 55 56 /* get full path crc32 */ 57 uint32_t dfs_dentry_full_path_crc32(struct dfs_dentry* dentry); 58 59 int dfs_dentry_init(void); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif /*__DFS_DENTRY_H__*/ 66