ext2.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 ued 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. /*
  33. * i_next_alloc_block is the logical (file-relative) number of the
  34. * most-recently-allocated block in this file. Yes, it is misnamed.
  35. * We use this for detecting linearly ascending allocation requests.
  36. */
  37. __u32 i_next_alloc_block;
  38. /*
  39. * i_next_alloc_goal is the *physical* companion to i_next_alloc_block.
  40. * it the the physical block number of the block which was most-recently
  41. * allocated to this file. This give us the goal (target) for the next
  42. * allocation when we detect linearly ascending requests.
  43. */
  44. __u32 i_next_alloc_goal;
  45. __u32 i_prealloc_block;
  46. __u32 i_prealloc_count;
  47. __u32 i_dir_start_lookup;
  48. #ifdef CONFIG_EXT2_FS_XATTR
  49. /*
  50. * Extended attributes can be read independently of the main file
  51. * data. Taking i_mutex even when reading would cause contention
  52. * between readers of EAs and writers of regular file data, so
  53. * instead we synchronize on xattr_sem when reading or changing
  54. * EAs.
  55. */
  56. struct rw_semaphore xattr_sem;
  57. #endif
  58. #ifdef CONFIG_EXT2_FS_POSIX_ACL
  59. struct posix_acl *i_acl;
  60. struct posix_acl *i_default_acl;
  61. #endif
  62. rwlock_t i_meta_lock;
  63. struct inode vfs_inode;
  64. };
  65. /*
  66. * Inode dynamic state flags
  67. */
  68. #define EXT2_STATE_NEW 0x00000001 /* inode is newly created */
  69. /*
  70. * Function prototypes
  71. */
  72. /*
  73. * Ok, these declarations are also in <linux/kernel.h> but none of the
  74. * ext2 source programs needs to include it so they are duplicated here.
  75. */
  76. static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
  77. {
  78. return container_of(inode, struct ext2_inode_info, vfs_inode);
  79. }
  80. /* balloc.c */
  81. extern int ext2_bg_has_super(struct super_block *sb, int group);
  82. extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
  83. extern int ext2_new_block (struct inode *, unsigned long,
  84. __u32 *, __u32 *, int *);
  85. extern void ext2_free_blocks (struct inode *, unsigned long,
  86. unsigned long);
  87. extern unsigned long ext2_count_free_blocks (struct super_block *);
  88. extern unsigned long ext2_count_dirs (struct super_block *);
  89. extern void ext2_check_blocks_bitmap (struct super_block *);
  90. extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
  91. unsigned int block_group,
  92. struct buffer_head ** bh);
  93. /* dir.c */
  94. extern int ext2_add_link (struct dentry *, struct inode *);
  95. extern ino_t ext2_inode_by_name(struct inode *, struct dentry *);
  96. extern int ext2_make_empty(struct inode *, struct inode *);
  97. extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct dentry *, struct page **);
  98. extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
  99. extern int ext2_empty_dir (struct inode *);
  100. extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
  101. extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *);
  102. /* fsync.c */
  103. extern int ext2_sync_file (struct file *, struct dentry *, int);
  104. /* ialloc.c */
  105. extern struct inode * ext2_new_inode (struct inode *, int);
  106. extern void ext2_free_inode (struct inode *);
  107. extern unsigned long ext2_count_free_inodes (struct super_block *);
  108. extern void ext2_check_inodes_bitmap (struct super_block *);
  109. extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
  110. /* inode.c */
  111. extern void ext2_read_inode (struct inode *);
  112. extern int ext2_write_inode (struct inode *, int);
  113. extern void ext2_put_inode (struct inode *);
  114. extern void ext2_delete_inode (struct inode *);
  115. extern int ext2_sync_inode (struct inode *);
  116. extern void ext2_discard_prealloc (struct inode *);
  117. extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
  118. extern void ext2_truncate (struct inode *);
  119. extern int ext2_setattr (struct dentry *, struct iattr *);
  120. extern void ext2_set_inode_flags(struct inode *inode);
  121. /* ioctl.c */
  122. extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
  123. unsigned long);
  124. extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
  125. /* namei.c */
  126. struct dentry *ext2_get_parent(struct dentry *child);
  127. /* super.c */
  128. extern void ext2_error (struct super_block *, const char *, const char *, ...)
  129. __attribute__ ((format (printf, 3, 4)));
  130. extern void ext2_warning (struct super_block *, const char *, const char *, ...)
  131. __attribute__ ((format (printf, 3, 4)));
  132. extern void ext2_update_dynamic_rev (struct super_block *sb);
  133. extern void ext2_write_super (struct super_block *);
  134. /*
  135. * Inodes and files operations
  136. */
  137. /* dir.c */
  138. extern const struct file_operations ext2_dir_operations;
  139. /* file.c */
  140. extern const struct inode_operations ext2_file_inode_operations;
  141. extern const struct file_operations ext2_file_operations;
  142. extern const struct file_operations ext2_xip_file_operations;
  143. /* inode.c */
  144. extern const struct address_space_operations ext2_aops;
  145. extern const struct address_space_operations ext2_aops_xip;
  146. extern const struct address_space_operations ext2_nobh_aops;
  147. /* namei.c */
  148. extern const struct inode_operations ext2_dir_inode_operations;
  149. extern const struct inode_operations ext2_special_inode_operations;
  150. /* symlink.c */
  151. extern const struct inode_operations ext2_fast_symlink_inode_operations;
  152. extern const struct inode_operations ext2_symlink_inode_operations;