1 diff -rupN linux-2.6.27.21-0.1_1//fs/ext4/ext4.h linux-2.6.27.21-0.1_2//fs/ext4/ext4.h
2 --- linux-2.6.27.21-0.1_1//fs/ext4/ext4.h 2009-08-24 15:32:00.000000000 +0530
3 +++ linux-2.6.27.21-0.1_2//fs/ext4/ext4.h 2009-08-24 15:32:55.000000000 +0530
4 @@ -1171,6 +1171,18 @@ extern int ext4_fiemap(struct inode *, s
6 extern int ext4_ext_migrate(struct inode *);
8 +extern struct inode *ext4_create_inode(handle_t *handle,
9 + struct inode * dir, int mode);
10 +extern int ext4_add_entry(handle_t *handle, struct dentry *dentry,
11 + struct inode *inode);
12 +extern int ext4_delete_entry(handle_t *handle, struct inode * dir,
13 + struct ext4_dir_entry_2 * de_del,
14 + struct buffer_head * bh);
15 +extern struct buffer_head * ext4_find_entry (struct inode *dir,
16 + const struct qstr *d_name,
17 + struct ext4_dir_entry_2 ** res_dir);
18 +extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir,
19 + struct inode *inode);
20 extern int ext4_orphan_add(handle_t *, struct inode *);
21 extern int ext4_orphan_del(handle_t *, struct inode *);
22 extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
23 diff -rupN linux-2.6.27.21-0.1_1//fs/ext4/namei.c linux-2.6.27.21-0.1_2//fs/ext4/namei.c
24 --- linux-2.6.27.21-0.1_1//fs/ext4/namei.c 2009-08-24 15:32:00.000000000 +0530
25 +++ linux-2.6.27.21-0.1_2//fs/ext4/namei.c 2009-08-24 15:43:56.000000000 +0530
30 +#include <linux/module.h>
32 #include <linux/pagemap.h>
33 #include <linux/jbd2.h>
34 @@ -882,9 +883,9 @@ static inline int search_dirblock(struct
35 * The returned buffer_head has ->b_count elevated. The caller is expected
36 * to brelse() it when appropriate.
38 -static struct buffer_head * ext4_find_entry (struct inode *dir,
39 - const struct qstr *d_name,
40 - struct ext4_dir_entry_2 ** res_dir)
41 +struct buffer_head * ext4_find_entry (struct inode *dir,
42 + const struct qstr *d_name,
43 + struct ext4_dir_entry_2 ** res_dir)
45 struct super_block *sb;
46 struct buffer_head *bh_use[NAMEI_RA_SIZE];
47 @@ -991,6 +992,7 @@ cleanup_and_exit:
48 brelse(bh_use[ra_ptr]);
51 +EXPORT_SYMBOL(ext4_find_entry);
53 static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
54 struct ext4_dir_entry_2 **res_dir, int *err)
55 @@ -1511,8 +1513,8 @@ static int make_indexed_dir(handle_t *ha
56 * may not sleep between calling this and putting something into
57 * the entry, as someone else might have used it while you slept.
59 -static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
60 - struct inode *inode)
61 +int ext4_add_entry(handle_t *handle, struct dentry *dentry,
62 + struct inode *inode)
64 struct inode *dir = dentry->d_parent->d_inode;
65 struct buffer_head *bh;
66 @@ -1557,6 +1559,7 @@ static int ext4_add_entry(handle_t *hand
67 de->rec_len = ext4_rec_len_to_disk(blocksize);
68 return add_dirent_to_buf(handle, dentry, inode, de, bh);
70 +EXPORT_SYMBOL(ext4_add_entry);
73 * Returns 0 for success, or a negative error value
74 @@ -1699,10 +1702,10 @@ cleanup:
75 * ext4_delete_entry deletes a directory entry by merging it with the
78 -static int ext4_delete_entry(handle_t *handle,
80 - struct ext4_dir_entry_2 *de_del,
81 - struct buffer_head *bh)
82 +int ext4_delete_entry(handle_t *handle,
84 + struct ext4_dir_entry_2 *de_del,
85 + struct buffer_head *bh)
87 struct ext4_dir_entry_2 *de, *pde;
89 @@ -1733,7 +1736,7 @@ static int ext4_delete_entry(handle_t *h
94 +EXPORT_SYMBOL(ext4_delete_entry);
96 * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2,
97 * since this indicates that nlinks count was previously 1.
98 @@ -1796,6 +1799,26 @@ static unsigned ext4_dentry_goal(struct
102 +struct inode * ext4_create_inode(handle_t *handle, struct inode * dir, int mode)
104 + struct inode *inode;
106 + inode = ext4_new_inode(handle, dir, mode);
107 + if (!IS_ERR(inode)) {
108 + if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) {
109 +#ifdef CONFIG_LDISKFS_FS_XATTR
110 + inode->i_op = &ext4_special_inode_operations;
113 + inode->i_op = &ext4_file_inode_operations;
114 + inode->i_fop = &ext4_file_operations;
115 + ext4_set_aops(inode);
120 +EXPORT_SYMBOL(ext4_create_inode);
123 * By the time this is called, we already have created
124 * the directory cache entry for the new file, but it
125 @@ -1872,51 +1895,43 @@ retry:
129 -static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
130 +/* Initialize @inode as a subdirectory of @dir, and add the
131 + * "." and ".." entries into the first directory block. */
132 +int ext4_add_dot_dotdot(handle_t *handle, struct inode * dir,
133 + struct inode *inode)
136 - struct inode *inode;
137 - struct buffer_head *dir_block;
138 - struct ext4_dir_entry_2 *de;
139 - int err, retries = 0;
141 - if (EXT4_DIR_LINK_MAX(dir))
143 + struct buffer_head * dir_block;
144 + struct ext4_dir_entry_2 * de;
148 - handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
149 - EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
150 - 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
152 return PTR_ERR(handle);
157 - inode = ext4_new_inode_goal(handle, dir, S_IFDIR | mode,
158 - ext4_dentry_goal(dir->i_sb, dentry));
159 - err = PTR_ERR(inode);
163 inode->i_op = &ext4_dir_inode_operations;
164 inode->i_fop = &ext4_dir_operations;
165 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
166 - dir_block = ext4_bread(handle, inode, 0, 1, &err);
168 - goto out_clear_inode;
169 + dir_block = ext4_bread (handle, inode, 0, 1, &err);
171 + clear_nlink(inode);
172 + ext4_mark_inode_dirty(handle, inode);
176 BUFFER_TRACE(dir_block, "get_write_access");
177 ext4_journal_get_write_access(handle, dir_block);
178 de = (struct ext4_dir_entry_2 *) dir_block->b_data;
179 de->inode = cpu_to_le32(inode->i_ino);
181 de->rec_len = ext4_rec_len_to_disk(EXT4_DIR_REC_LEN(de->name_len));
182 - strcpy(de->name, ".");
183 + strcpy (de->name, ".");
184 ext4_set_de_type(dir->i_sb, de, S_IFDIR);
185 de = ext4_next_entry(de);
186 de->inode = cpu_to_le32(dir->i_ino);
187 de->rec_len = ext4_rec_len_to_disk(inode->i_sb->s_blocksize -
188 - EXT4_DIR_REC_LEN(1));
189 + EXT4_DIR_REC_LEN(1));
191 strcpy(de->name, "..");
192 ext4_set_de_type(dir->i_sb, de, S_IFDIR);
193 @@ -1925,9 +1940,43 @@ retry:
194 ext4_journal_dirty_metadata(handle, dir_block);
196 ext4_mark_inode_dirty(handle, inode);
200 +EXPORT_SYMBOL(ext4_add_dot_dotdot);
203 +static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
206 + struct inode *inode;
207 + int err, retries = 0;
209 + if (EXT4_DIR_LINK_MAX(dir))
213 + handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
214 + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
215 + 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
216 + if (IS_ERR(handle))
217 + return PTR_ERR(handle);
219 + if (IS_DIRSYNC(dir))
220 + handle->h_sync = 1;
222 + inode = ext4_new_inode_goal(handle, dir, S_IFDIR | mode,
223 + ext4_dentry_goal(dir->i_sb, dentry));
224 + err = PTR_ERR(inode);
228 + err = ext4_add_dot_dotdot(handle, dir, inode);
232 err = ext4_add_entry(handle, dentry, inode);
236 ext4_mark_inode_dirty(handle, inode);