dir.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * dir.h
  4. *
  5. * Function prototypes
  6. *
  7. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  8. */
  9. #ifndef OCFS2_DIR_H
  10. #define OCFS2_DIR_H
  11. struct ocfs2_dx_hinfo {
  12. u32 major_hash;
  13. u32 minor_hash;
  14. };
  15. struct ocfs2_dir_lookup_result {
  16. struct buffer_head *dl_leaf_bh; /* Unindexed leaf
  17. * block */
  18. struct ocfs2_dir_entry *dl_entry; /* Target dirent in
  19. * unindexed leaf */
  20. struct buffer_head *dl_dx_root_bh; /* Root of indexed
  21. * tree */
  22. struct buffer_head *dl_dx_leaf_bh; /* Indexed leaf block */
  23. struct ocfs2_dx_entry *dl_dx_entry; /* Target dx_entry in
  24. * indexed leaf */
  25. struct ocfs2_dx_hinfo dl_hinfo; /* Name hash results */
  26. struct buffer_head *dl_prev_leaf_bh;/* Previous entry in
  27. * dir free space
  28. * list. NULL if
  29. * previous entry is
  30. * dx root block. */
  31. };
  32. void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res);
  33. int ocfs2_find_entry(const char *name, int namelen,
  34. struct inode *dir,
  35. struct ocfs2_dir_lookup_result *lookup);
  36. int ocfs2_delete_entry(handle_t *handle,
  37. struct inode *dir,
  38. struct ocfs2_dir_lookup_result *res);
  39. int __ocfs2_add_entry(handle_t *handle,
  40. struct inode *dir,
  41. const char *name, int namelen,
  42. struct inode *inode, u64 blkno,
  43. struct buffer_head *parent_fe_bh,
  44. struct ocfs2_dir_lookup_result *lookup);
  45. static inline int ocfs2_add_entry(handle_t *handle,
  46. struct dentry *dentry,
  47. struct inode *inode, u64 blkno,
  48. struct buffer_head *parent_fe_bh,
  49. struct ocfs2_dir_lookup_result *lookup)
  50. {
  51. return __ocfs2_add_entry(handle, d_inode(dentry->d_parent),
  52. dentry->d_name.name, dentry->d_name.len,
  53. inode, blkno, parent_fe_bh, lookup);
  54. }
  55. int ocfs2_update_entry(struct inode *dir, handle_t *handle,
  56. struct ocfs2_dir_lookup_result *res,
  57. struct inode *new_entry_inode);
  58. int ocfs2_check_dir_for_entry(struct inode *dir,
  59. const char *name,
  60. int namelen);
  61. int ocfs2_empty_dir(struct inode *inode);
  62. int ocfs2_find_files_on_disk(const char *name,
  63. int namelen,
  64. u64 *blkno,
  65. struct inode *inode,
  66. struct ocfs2_dir_lookup_result *res);
  67. int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
  68. int namelen, u64 *blkno);
  69. int ocfs2_readdir(struct file *file, struct dir_context *ctx);
  70. int ocfs2_dir_foreach(struct inode *inode, struct dir_context *ctx);
  71. int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
  72. struct inode *dir,
  73. struct buffer_head *parent_fe_bh,
  74. const char *name,
  75. int namelen,
  76. struct ocfs2_dir_lookup_result *lookup);
  77. struct ocfs2_alloc_context;
  78. int ocfs2_fill_new_dir(struct ocfs2_super *osb,
  79. handle_t *handle,
  80. struct inode *parent,
  81. struct inode *inode,
  82. struct buffer_head *fe_bh,
  83. struct ocfs2_alloc_context *data_ac,
  84. struct ocfs2_alloc_context *meta_ac);
  85. int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh);
  86. struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
  87. void *data);
  88. #endif /* OCFS2_DIR_H */