blob: eed521d22cf08900f397444f0b743c2c53411143 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/fs.h>
2#include <linux/ext2_fs.h>
3
4/*
5 * second extended file system inode data in memory
6 */
7struct ext2_inode_info {
8 __le32 i_data[15];
9 __u32 i_flags;
10 __u32 i_faddr;
11 __u8 i_frag_no;
12 __u8 i_frag_size;
13 __u16 i_state;
14 __u32 i_file_acl;
15 __u32 i_dir_acl;
16 __u32 i_dtime;
17
18 /*
19 * i_block_group is the number of the block group which contains
20 * this file's inode. Constant across the lifetime of the inode,
21 * it is ued for making block allocation decisions - we try to
22 * place a file's data blocks near its inode block, and new inodes
23 * near to their parent directory's inode.
24 */
25 __u32 i_block_group;
26
27 /*
28 * i_next_alloc_block is the logical (file-relative) number of the
29 * most-recently-allocated block in this file. Yes, it is misnamed.
30 * We use this for detecting linearly ascending allocation requests.
31 */
32 __u32 i_next_alloc_block;
33
34 /*
35 * i_next_alloc_goal is the *physical* companion to i_next_alloc_block.
36 * it the the physical block number of the block which was most-recently
37 * allocated to this file. This give us the goal (target) for the next
38 * allocation when we detect linearly ascending requests.
39 */
40 __u32 i_next_alloc_goal;
41 __u32 i_prealloc_block;
42 __u32 i_prealloc_count;
43 __u32 i_dir_start_lookup;
44#ifdef CONFIG_EXT2_FS_XATTR
45 /*
46 * Extended attributes can be read independently of the main file
47 * data. Taking i_sem even when reading would cause contention
48 * between readers of EAs and writers of regular file data, so
49 * instead we synchronize on xattr_sem when reading or changing
50 * EAs.
51 */
52 struct rw_semaphore xattr_sem;
53#endif
54#ifdef CONFIG_EXT2_FS_POSIX_ACL
55 struct posix_acl *i_acl;
56 struct posix_acl *i_default_acl;
57#endif
58 rwlock_t i_meta_lock;
59 struct inode vfs_inode;
60};
61
62/*
63 * Inode dynamic state flags
64 */
65#define EXT2_STATE_NEW 0x00000001 /* inode is newly created */
66
67
68/*
69 * Function prototypes
70 */
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
77static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
78{
79 return container_of(inode, struct ext2_inode_info, vfs_inode);
80}
81
82/* balloc.c */
83extern int ext2_bg_has_super(struct super_block *sb, int group);
84extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
85extern int ext2_new_block (struct inode *, unsigned long,
86 __u32 *, __u32 *, int *);
87extern void ext2_free_blocks (struct inode *, unsigned long,
88 unsigned long);
89extern unsigned long ext2_count_free_blocks (struct super_block *);
90extern unsigned long ext2_count_dirs (struct super_block *);
91extern void ext2_check_blocks_bitmap (struct super_block *);
92extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
93 unsigned int block_group,
94 struct buffer_head ** bh);
95
96/* dir.c */
97extern int ext2_add_link (struct dentry *, struct inode *);
98extern ino_t ext2_inode_by_name(struct inode *, struct dentry *);
99extern int ext2_make_empty(struct inode *, struct inode *);
100extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct dentry *, struct page **);
101extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
102extern int ext2_empty_dir (struct inode *);
103extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
104extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *);
105
106/* fsync.c */
107extern int ext2_sync_file (struct file *, struct dentry *, int);
108
109/* ialloc.c */
110extern struct inode * ext2_new_inode (struct inode *, int);
111extern void ext2_free_inode (struct inode *);
112extern unsigned long ext2_count_free_inodes (struct super_block *);
113extern void ext2_check_inodes_bitmap (struct super_block *);
114extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
115
116/* inode.c */
117extern void ext2_read_inode (struct inode *);
118extern int ext2_write_inode (struct inode *, int);
Bernard Blackhame072c6f2005-04-16 15:25:45 -0700119extern void ext2_put_inode (struct inode *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120extern void ext2_delete_inode (struct inode *);
121extern int ext2_sync_inode (struct inode *);
122extern void ext2_discard_prealloc (struct inode *);
123extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
124extern void ext2_truncate (struct inode *);
125extern int ext2_setattr (struct dentry *, struct iattr *);
126extern void ext2_set_inode_flags(struct inode *inode);
127
128/* ioctl.c */
129extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
130 unsigned long);
131
132/* super.c */
133extern void ext2_error (struct super_block *, const char *, const char *, ...)
134 __attribute__ ((format (printf, 3, 4)));
135extern void ext2_warning (struct super_block *, const char *, const char *, ...)
136 __attribute__ ((format (printf, 3, 4)));
137extern void ext2_update_dynamic_rev (struct super_block *sb);
138extern void ext2_write_super (struct super_block *);
139
140/*
141 * Inodes and files operations
142 */
143
144/* dir.c */
145extern struct file_operations ext2_dir_operations;
146
147/* file.c */
148extern struct inode_operations ext2_file_inode_operations;
149extern struct file_operations ext2_file_operations;
Carsten Otte6d791252005-06-23 22:05:26 -0700150extern struct file_operations ext2_xip_file_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152/* inode.c */
153extern struct address_space_operations ext2_aops;
Carsten Otte6d791252005-06-23 22:05:26 -0700154extern struct address_space_operations ext2_aops_xip;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155extern struct address_space_operations ext2_nobh_aops;
156
157/* namei.c */
158extern struct inode_operations ext2_dir_inode_operations;
159extern struct inode_operations ext2_special_inode_operations;
160
161/* symlink.c */
162extern struct inode_operations ext2_fast_symlink_inode_operations;
163extern struct inode_operations ext2_symlink_inode_operations;