dfs_dentry.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef __DFS_DENTRY_H__
  11. #define __DFS_DENTRY_H__
  12. #include "dfs_file.h"
  13. #include "dfs_fs.h"
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. struct dfs_mnt;
  19. struct dfs_vnode;
  20. struct dfs_dentry
  21. {
  22. rt_list_t hashlist;
  23. uint32_t flags;
  24. #define DENTRY_IS_MOUNTED 0x1 /* dentry is mounted */
  25. #define DENTRY_IS_ALLOCED 0x2 /* dentry is allocated */
  26. #define DENTRY_IS_ADDHASH 0x4 /* dentry was added into hash table */
  27. #define DENTRY_IS_OPENED 0x8 /* dentry was opened. */
  28. char *pathname; /* the pathname under mounted file sytem */
  29. struct dfs_vnode *vnode; /* the vnode of this dentry */
  30. struct dfs_mnt *mnt; /* which mounted file system does this dentry belong to */
  31. rt_atomic_t ref_count; /* the reference count */
  32. };
  33. struct dfs_dentry *dfs_dentry_create(struct dfs_mnt *mnt, char *fullpath);
  34. struct dfs_dentry *dfs_dentry_unref(struct dfs_dentry *dentry);
  35. struct dfs_dentry *dfs_dentry_ref(struct dfs_dentry *dentry);
  36. void dfs_dentry_insert(struct dfs_dentry *dentry);
  37. struct dfs_dentry *dfs_dentry_lookup(struct dfs_mnt *mnt, const char *path, uint32_t flags);
  38. /* get full path of a dentry */
  39. char* dfs_dentry_full_path(struct dfs_dentry* dentry);
  40. /* get pathname (with mnt path) of a dentry */
  41. char* dfs_dentry_pathname(struct dfs_dentry* dentry);
  42. /* get full path crc32 */
  43. uint32_t dfs_dentry_full_path_crc32(struct dfs_dentry* dentry);
  44. int dfs_dentry_init(void);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /*__DFS_DENTRY_H__*/