dfs_dentry.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_create_rela(struct dfs_mnt *mnt, char *rela_path);
  35. struct dfs_dentry *dfs_dentry_unref(struct dfs_dentry *dentry);
  36. struct dfs_dentry *dfs_dentry_ref(struct dfs_dentry *dentry);
  37. void dfs_dentry_insert(struct dfs_dentry *dentry);
  38. struct dfs_dentry *dfs_dentry_lookup(struct dfs_mnt *mnt, const char *path, uint32_t flags);
  39. /* get full path of a dentry */
  40. char* dfs_dentry_full_path(struct dfs_dentry* dentry);
  41. /* get pathname (with mnt path) of a dentry */
  42. char* dfs_dentry_pathname(struct dfs_dentry* dentry);
  43. /* get full path crc32 */
  44. uint32_t dfs_dentry_full_path_crc32(struct dfs_dentry* dentry);
  45. int dfs_dentry_init(void);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif /*__DFS_DENTRY_H__*/