ext2.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #include <linux/fs.h>
  2. #include <linux/ext2_fs.h>
  3. /*
  4. * ext2 mount options
  5. */
  6. struct ext2_mount_options {
  7. unsigned long s_mount_opt;
  8. uid_t s_resuid;
  9. gid_t s_resgid;
  10. };
  11. /*
  12. * second extended file system inode data in memory
  13. */
  14. struct ext2_inode_info {
  15. __le32 i_data[15];
  16. __u32 i_flags;
  17. __u32 i_faddr;
  18. __u8 i_frag_no;
  19. __u8 i_frag_size;
  20. __u16 i_state;
  21. __u32 i_file_acl;
  22. __u32 i_dir_acl;
  23. __u32 i_dtime;
  24. /*
  25. * i_block_group is the number of the block group which contains
  26. * this file's inode. Constant across the lifetime of the inode,
  27. * it is used for making block allocation decisions - we try to
  28. * place a file's data blocks near its inode block, and new inodes
  29. * near to their parent directory's inode.
  30. */
  31. __u32 i_block_group;
  32. /* block reservation info */
  33. struct ext2_block_alloc_info *i_block_alloc_info;
  34. __u32 i_dir_start_lookup;
  35. #ifdef CONFIG_EXT2_FS_XATTR
  36. /*
  37. * Extended attributes can be read independently of the main file
  38. * data. Taking i_mutex even when reading would cause contention
  39. * between readers of EAs and writers of regular file data, so
  40. * instead we synchronize on xattr_sem when reading or changing
  41. * EAs.
  42. */
  43. struct rw_semaphore xattr_sem;
  44. #endif
  45. rwlock_t i_meta_lock;
  46. /*
  47. * truncate_mutex is for serialising ext2_truncate() against
  48. * ext2_getblock(). It also protects the internals of the inode's
  49. * reservation data structures: ext2_reserve_window and
  50. * ext2_reserve_window_node.
  51. */
  52. struct mutex truncate_mutex;
  53. struct inode vfs_inode;
  54. struct list_head i_orphan; /* unlinked but open inodes */
  55. };
  56. /*
  57. * Inode dynamic state flags
  58. */
  59. #define EXT2_STATE_NEW 0x00000001 /* inode is newly created */
  60. /*
  61. * Function prototypes
  62. */
  63. /*
  64. * Ok, these declarations are also in <linux/kernel.h> but none of the
  65. * ext2 source programs needs to include it so they are duplicated here.
  66. */
  67. static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
  68. {
  69. return container_of(inode, struct ext2_inode_info, vfs_inode);
  70. }
  71. /* balloc.c */
  72. extern int ext2_bg_has_super(struct super_block *sb, int group);
  73. extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
  74. extern ext2_fsblk_t ext2_new_block(struct inode *, unsigned long, int *);
  75. extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long,
  76. unsigned long *, int *);
  77. extern void ext2_free_blocks (struct inode *, unsigned long,
  78. unsigned long);
  79. extern unsigned long ext2_count_free_blocks (struct super_block *);
  80. extern unsigned long ext2_count_dirs (struct super_block *);
  81. extern void ext2_check_blocks_bitmap (struct super_block *);
  82. extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
  83. unsigned int block_group,
  84. struct buffer_head ** bh);
  85. extern void ext2_discard_reservation (struct inode *);
  86. extern int ext2_should_retry_alloc(struct super_block *sb, int *retries);
  87. extern void ext2_init_block_alloc_info(struct inode *);
  88. extern void ext2_rsv_window_add(struct super_block *sb, struct ext2_reserve_window_node *rsv);
  89. /* dir.c */
  90. extern int ext2_add_link (struct dentry *, struct inode *);
  91. extern ino_t ext2_inode_by_name(struct inode *, struct qstr *);
  92. extern int ext2_make_empty(struct inode *, struct inode *);
  93. extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct qstr *, struct page **);
  94. extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
  95. extern int ext2_empty_dir (struct inode *);
  96. extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
  97. extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int);
  98. /* ialloc.c */
  99. extern struct inode * ext2_new_inode (struct inode *, int, const struct qstr *);
  100. extern void ext2_free_inode (struct inode *);
  101. extern unsigned long ext2_count_free_inodes (struct super_block *);
  102. extern void ext2_check_inodes_bitmap (struct super_block *);
  103. extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
  104. /* inode.c */
  105. extern struct inode *ext2_iget (struct super_block *, unsigned long);
  106. extern int ext2_write_inode (struct inode *, struct writeback_control *);
  107. extern void ext2_evict_inode(struct inode *);
  108. extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
  109. extern int ext2_setattr (struct dentry *, struct iattr *);
  110. extern void ext2_set_inode_flags(struct inode *inode);
  111. extern void ext2_get_inode_flags(struct ext2_inode_info *);
  112. extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  113. u64 start, u64 len);
  114. /* ioctl.c */
  115. extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
  116. extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
  117. /* namei.c */
  118. struct dentry *ext2_get_parent(struct dentry *child);
  119. /* super.c */
  120. extern void ext2_error (struct super_block *, const char *, const char *, ...)
  121. __attribute__ ((format (printf, 3, 4)));
  122. extern void ext2_msg(struct super_block *, const char *, const char *, ...)
  123. __attribute__ ((format (printf, 3, 4)));
  124. extern void ext2_update_dynamic_rev (struct super_block *sb);
  125. extern void ext2_write_super (struct super_block *);
  126. /*
  127. * Inodes and files operations
  128. */
  129. /* dir.c */
  130. extern const struct file_operations ext2_dir_operations;
  131. /* file.c */
  132. extern int ext2_fsync(struct file *file, int datasync);
  133. extern const struct inode_operations ext2_file_inode_operations;
  134. extern const struct file_operations ext2_file_operations;
  135. extern const struct file_operations ext2_xip_file_operations;
  136. /* inode.c */
  137. extern const struct address_space_operations ext2_aops;
  138. extern const struct address_space_operations ext2_aops_xip;
  139. extern const struct address_space_operations ext2_nobh_aops;
  140. /* namei.c */
  141. extern const struct inode_operations ext2_dir_inode_operations;
  142. extern const struct inode_operations ext2_special_inode_operations;
  143. /* symlink.c */
  144. extern const struct inode_operations ext2_fast_symlink_inode_operations;
  145. extern const struct inode_operations ext2_symlink_inode_operations;
  146. static inline ext2_fsblk_t
  147. ext2_group_first_block_no(struct super_block *sb, unsigned long group_no)
  148. {
  149. return group_no * (ext2_fsblk_t)EXT2_BLOCKS_PER_GROUP(sb) +
  150. le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block);
  151. }
  152. #define ext2_set_bit __test_and_set_bit_le
  153. #define ext2_clear_bit __test_and_clear_bit_le
  154. #define ext2_test_bit test_bit_le
  155. #define ext2_find_first_zero_bit find_first_zero_bit_le
  156. #define ext2_find_next_zero_bit find_next_zero_bit_le