1 Index: linux-2.6.32.i386/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-2.6.32.i386.orig/fs/ext4/ext4.h 2010-04-16 04:57:39.000000000 +0530
4 +++ linux-2.6.32.i386/fs/ext4/ext4.h 2010-04-16 05:27:02.000000000 +0530
6 extern int ext4_orphan_del(handle_t *, struct inode *);
7 extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
8 __u32 start_minor_hash, __u32 *next_hash);
9 +extern struct inode *ext4_create_inode(handle_t *handle,
10 + struct inode * dir, int mode);
11 +extern int ext4_add_entry(handle_t *handle, struct dentry *dentry,
12 + struct inode *inode);
13 +extern int ext4_delete_entry(handle_t *handle, struct inode * dir,
14 + struct ext4_dir_entry_2 * de_del,
15 + struct buffer_head * bh);
16 +extern struct buffer_head * ext4_find_entry(struct inode *dir,
17 + const struct qstr *d_name,
18 + struct ext4_dir_entry_2 ** res_dir);
19 +#define ll_ext4_find_entry(inode, dentry, res_dir) ext4_find_entry(inode, &(dentry)->d_name, res_dir)
20 +extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir,
21 + struct inode *inode);
24 extern int ext4_group_add(struct super_block *sb,
25 Index: linux-2.6.32.i386/fs/ext4/namei.c
26 ===================================================================
27 --- linux-2.6.32.i386.orig/fs/ext4/namei.c 2010-04-16 04:57:39.000000000 +0530
28 +++ linux-2.6.32.i386/fs/ext4/namei.c 2010-04-16 05:28:25.000000000 +0530
33 +#include <linux/module.h>
35 #include <linux/pagemap.h>
36 #include <linux/jbd2.h>
38 * The returned buffer_head has ->b_count elevated. The caller is expected
39 * to brelse() it when appropriate.
41 -static struct buffer_head * ext4_find_entry (struct inode *dir,
42 - const struct qstr *d_name,
43 - struct ext4_dir_entry_2 ** res_dir)
44 +struct buffer_head * ext4_find_entry(struct inode *dir,
45 + const struct qstr *d_name,
46 + struct ext4_dir_entry_2 ** res_dir)
48 struct super_block *sb;
49 struct buffer_head *bh_use[NAMEI_RA_SIZE];
51 brelse(bh_use[ra_ptr]);
54 +EXPORT_SYMBOL(ext4_find_entry);
56 static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
57 struct ext4_dir_entry_2 **res_dir, int *err)
59 * may not sleep between calling this and putting something into
60 * the entry, as someone else might have used it while you slept.
62 -static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
63 - struct inode *inode)
64 +int ext4_add_entry(handle_t *handle, struct dentry *dentry,
65 + struct inode *inode)
67 struct inode *dir = dentry->d_parent->d_inode;
68 struct buffer_head *bh;
73 +EXPORT_SYMBOL(ext4_add_entry);
76 * Returns 0 for success, or a negative error value
77 @@ -1728,10 +1731,10 @@
78 * ext4_delete_entry deletes a directory entry by merging it with the
81 -static int ext4_delete_entry(handle_t *handle,
83 - struct ext4_dir_entry_2 *de_del,
84 - struct buffer_head *bh)
85 +int ext4_delete_entry(handle_t *handle,
87 + struct ext4_dir_entry_2 *de_del,
88 + struct buffer_head *bh)
90 struct ext4_dir_entry_2 *de, *pde;
91 unsigned int blocksize = dir->i_sb->s_blocksize;
97 +EXPORT_SYMBOL(ext4_delete_entry);
99 * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2,
100 * since this indicates that nlinks count was previously 1.
101 @@ -1831,6 +1834,26 @@
105 +struct inode * ext4_create_inode(handle_t *handle, struct inode * dir, int mode)
107 + struct inode *inode;
109 + inode = ext4_new_inode(handle, dir, mode, 0, 0);
110 + if (!IS_ERR(inode)) {
111 + if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) {
112 +#ifdef CONFIG_LDISKFS_FS_XATTR
113 + inode->i_op = &ext4_special_inode_operations;
116 + inode->i_op = &ext4_file_inode_operations;
117 + inode->i_fop = &ext4_file_operations;
118 + ext4_set_aops(inode);
123 +EXPORT_SYMBOL(ext4_create_inode);
126 * By the time this is called, we already have created
127 * the directory cache entry for the new file, but it
128 @@ -1905,40 +1928,33 @@
132 -static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
133 +/* Initialize @inode as a subdirectory of @dir, and add the
134 + * "." and ".." entries into the first directory block. */
135 +int ext4_add_dot_dotdot(handle_t *handle, struct inode * dir,
136 + struct inode *inode)
139 - struct inode *inode;
140 - struct buffer_head *dir_block;
141 - struct ext4_dir_entry_2 *de;
142 + struct buffer_head * dir_block;
143 + struct ext4_dir_entry_2 * de;
144 unsigned int blocksize = dir->i_sb->s_blocksize;
145 - int err, retries = 0;
147 - if (EXT4_DIR_LINK_MAX(dir))
152 - handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
153 - EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
154 - EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
156 return PTR_ERR(handle);
159 ext4_handle_sync(handle);
161 - inode = ext4_new_inode(handle, dir, S_IFDIR | mode,
162 - &dentry->d_name, 0);
163 - err = PTR_ERR(inode);
167 inode->i_op = &ext4_dir_inode_operations;
168 inode->i_fop = &ext4_dir_operations;
169 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
170 dir_block = ext4_bread(handle, inode, 0, 1, &err);
172 - goto out_clear_inode;
174 + clear_nlink(inode);
175 + ext4_mark_inode_dirty(handle, inode);
179 BUFFER_TRACE(dir_block, "get_write_access");
180 ext4_journal_get_write_access(handle, dir_block);
181 de = (struct ext4_dir_entry_2 *) dir_block->b_data;
182 @@ -1960,9 +1976,43 @@
183 ext4_handle_dirty_metadata(handle, dir, dir_block);
185 ext4_mark_inode_dirty(handle, inode);
189 +EXPORT_SYMBOL(ext4_add_dot_dotdot);
192 +static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
195 + struct inode *inode;
196 + int err, retries = 0;
198 + if (EXT4_DIR_LINK_MAX(dir))
202 + handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
203 + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
204 + 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
205 + if (IS_ERR(handle))
206 + return PTR_ERR(handle);
208 + if (IS_DIRSYNC(dir))
209 + handle->h_sync = 1;
211 + inode = ext4_new_inode(handle, dir, S_IFDIR | mode,
212 + &dentry->d_name, ext4_dentry_goal(dir->i_sb, dentry));
213 + err = PTR_ERR(inode);
217 + err = ext4_add_dot_dotdot(handle, dir, inode);
221 err = ext4_add_entry(handle, dentry, inode);
225 unlock_new_inode(inode);
226 ext4_mark_inode_dirty(handle, inode);