dir.h 3.2 KB

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