1 Index: linux-2.6.7/fs/ext3/namei.c
2 ===================================================================
3 --- linux-2.6.7.orig/fs/ext3/namei.c 2004-09-12 18:53:33.000000000 +0400
4 +++ linux-2.6.7/fs/ext3/namei.c 2004-09-12 19:14:37.000000000 +0400
9 +#include <linux/module.h>
11 #include <linux/pagemap.h>
12 #include <linux/jbd.h>
13 @@ -1150,6 +1151,23 @@
16 unsigned long ino = le32_to_cpu(de->inode);
17 + unsigned type = de->file_type;
19 + mds = (__u32 *)((char *) de + EXT3_DIR_REC_LEN(de->name_len));
20 + if ((type & 128) && EXT3_HAS_INCOMPAT_FEATURE(dir->i_sb,
21 + EXT3_FEATURE_INCOMPAT_MDSNUM) &&
22 + mds[0] != EXT3_SB(dir->i_sb)->s_mdsnum) {
23 + struct ext3_super_block *es;
24 + es = EXT3_SB(dir->i_sb)->s_es;
26 + dentry->d_flags |= DCACHE_CROSS_REF;
27 + dentry->d_generation = mds[1];
28 + dentry->d_mdsnum = mds[0];
29 + dentry->d_inum = ino;
30 + ext3_unlock_htree(dir, lock);
31 + d_add(dentry, NULL);
34 ext3_unlock_htree(dir, lock);
36 inode = iget(dir->i_sb, ino);
39 struct ext3_dir_entry_2 *de =
40 (struct ext3_dir_entry_2 *) (from + map->offs);
41 - rec_len = EXT3_DIR_REC_LEN(de->name_len);
42 + rec_len = EXT3_DIR_REC_LEN_DE(de);
43 memcpy (to, de, rec_len);
44 ((struct ext3_dir_entry_2 *) to)->rec_len =
47 next = (struct ext3_dir_entry_2 *) ((char *) de +
48 le16_to_cpu(de->rec_len));
49 if (de->inode && de->name_len) {
50 - rec_len = EXT3_DIR_REC_LEN(de->name_len);
51 + rec_len = EXT3_DIR_REC_LEN_DE(de);
53 memmove(to, de, rec_len);
54 to->rec_len = cpu_to_le16(rec_len);
56 struct buffer_head * bh)
58 struct inode *dir = dentry->d_parent->d_inode;
59 + struct super_block *sb = dir->i_sb;
60 const char *name = dentry->d_name.name;
61 int namelen = dentry->d_name.len;
62 unsigned long offset = 0;
63 @@ -1369,6 +1388,10 @@
66 reclen = EXT3_DIR_REC_LEN(namelen);
67 + if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MDSNUM)
68 + && (dentry->d_flags & DCACHE_CROSS_REF)
69 + && (dentry->d_mdsnum != EXT3_SB(sb)->s_mdsnum))
70 + reclen += 8; /* we need space to store mds num */
72 de = (struct ext3_dir_entry_2 *)bh->b_data;
73 top = bh->b_data + dir->i_sb->s_blocksize - reclen;
78 - nlen = EXT3_DIR_REC_LEN(de->name_len);
79 + nlen = EXT3_DIR_REC_LEN_DE(de);
80 rlen = le16_to_cpu(de->rec_len);
81 if ((de->inode? rlen - nlen: rlen) >= reclen)
86 /* By now the buffer is marked for journaling */
87 - nlen = EXT3_DIR_REC_LEN(de->name_len);
88 + nlen = EXT3_DIR_REC_LEN_DE(de);
89 rlen = le16_to_cpu(de->rec_len);
91 struct ext3_dir_entry_2 *de1 =
92 @@ -1413,8 +1436,20 @@
93 de->file_type = EXT3_FT_UNKNOWN;
95 de->inode = cpu_to_le32(inode->i_ino);
96 - ext3_set_de_type(dir->i_sb, de, inode->i_mode);
98 + ext3_set_de_type(sb, de, inode->i_mode);
99 + } else if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MDSNUM)
100 + && (dentry->d_flags & DCACHE_CROSS_REF)) {
101 + if (dentry->d_mdsnum != EXT3_SB(sb)->s_mdsnum) {
103 + mds = (__u32 *)((char *)de + EXT3_DIR_REC_LEN(namelen));
104 + mds[0] = cpu_to_le32(dentry->d_mdsnum);
105 + mds[1] = cpu_to_le32(dentry->d_generation);
106 + de->inode = cpu_to_le32(dentry->d_inum);
107 + de->file_type = 128;
109 + de->inode = cpu_to_le32(dentry->d_inum);
113 de->name_len = namelen;
114 memcpy (de->name, name, namelen);
115 @@ -2721,6 +2756,81 @@
119 + * caller has to make sure directory is protected
121 +int ext3_add_dir_entry(struct dentry *dentry)
123 + struct inode *dir = dentry->d_parent->d_inode;
127 + handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS +
128 + EXT3_INDEX_EXTRA_TRANS_BLOCKS);
129 + if (IS_ERR(handle)) {
130 + return PTR_ERR(handle);
134 + handle->h_sync = 1;
136 + err = ext3_add_entry(handle, dentry, NULL);
137 + ext3_journal_stop(handle);
140 +EXPORT_SYMBOL(ext3_add_dir_entry);
142 + * caller has to make sure directory is protected
144 +int ext3_del_dir_entry(struct dentry *dentry)
146 + struct inode * inode;
147 + struct inode * dir = dentry->d_parent->d_inode;
148 + struct buffer_head * bh;
149 + struct ext3_dir_entry_2 * de;
154 + handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS);
155 + if (IS_ERR(handle)) {
156 + return PTR_ERR(handle);
160 + handle->h_sync = 1;
163 + bh = ext3_find_entry (dentry, &de, 1, &lock);
164 + ext3_unlock_htree(dir, lock);
168 + inode = dentry->d_inode;
172 + retval = ext3_delete_entry(handle, dir, de, bh);
175 + dir->i_ctime = dir->i_mtime = CURRENT_TIME;
176 + ext3_update_dx_flag(dir);
178 + inode->i_ctime = dir->i_ctime;
179 + ext3_mark_inode_dirty(handle, inode);
180 + if (S_ISDIR(inode->i_mode))
183 + ext3_mark_inode_dirty(handle, dir);
187 + ext3_journal_stop(handle);
192 +EXPORT_SYMBOL(ext3_del_dir_entry);
194 * directories can handle most operations...
196 struct inode_operations ext3_dir_inode_operations = {
197 Index: linux-2.6.7/fs/ext3/dir.c
198 ===================================================================
199 --- linux-2.6.7.orig/fs/ext3/dir.c 2004-08-26 17:11:31.000000000 +0400
200 +++ linux-2.6.7/fs/ext3/dir.c 2004-09-12 19:14:37.000000000 +0400
203 static unsigned char get_dtype(struct super_block *sb, int filetype)
205 + if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MDSNUM))
208 if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_FILETYPE) ||
209 (filetype >= EXT3_FT_MAX))
212 error_msg = "directory entry across blocks";
213 else if (le32_to_cpu(de->inode) >
214 le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count))
215 - error_msg = "inode out of bounds";
216 + if (de->file_type != 128)
217 + error_msg = "inode out of bounds";
219 if (error_msg != NULL)
220 ext3_error (dir->i_sb, function,
221 Index: linux-2.6.7/include/linux/ext3_fs.h
222 ===================================================================
223 --- linux-2.6.7.orig/include/linux/ext3_fs.h 2004-09-12 19:14:24.000000000 +0400
224 +++ linux-2.6.7/include/linux/ext3_fs.h 2004-09-12 19:15:12.000000000 +0400
226 __u16 s_reserved_word_pad;
227 __u32 s_default_mount_opts;
228 __u32 s_first_meta_bg; /* First metablock block group */
229 - __u32 s_reserved[190]; /* Padding to the end of the block */
231 + __u32 s_reserved[189]; /* Padding to the end of the block */
235 @@ -532,12 +533,14 @@
236 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
237 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
238 #define EXT3_FEATURE_INCOMPAT_META_BG 0x0010
239 +#define EXT3_FEATURE_INCOMPAT_MDSNUM 0x0020 /* direntry has mdsnum */
240 #define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
242 #define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
243 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
244 EXT3_FEATURE_INCOMPAT_RECOVER| \
245 EXT3_FEATURE_INCOMPAT_META_BG| \
246 + EXT3_FEATURE_INCOMPAT_MDSNUM| \
247 EXT3_FEATURE_INCOMPAT_EXTENTS)
248 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
249 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
251 #define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)
252 #define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \
254 +#define EXT3_DIR_REC_LEN_DE(de) (EXT3_DIR_REC_LEN((de)->name_len) + \
255 + (((de)->file_type & 128) ? 8 : 0))
258 * Hash Tree Directory indexing
259 * (c) Daniel Phillips, 2001
261 extern void ext3_ext_release(struct super_block *);
262 extern void ext3_extents_initialize_blockmap(handle_t *, struct inode *);
264 +extern int ext3_add_dir_entry(struct dentry *dentry);
266 +extern int ext3_del_dir_entry(struct dentry *dentry);
267 #endif /* __KERNEL__ */
269 #define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
270 Index: linux-2.6.7/include/linux/ext3_fs_sb.h
271 ===================================================================
272 --- linux-2.6.7.orig/include/linux/ext3_fs_sb.h 2004-09-12 18:53:33.000000000 +0400
273 +++ linux-2.6.7/include/linux/ext3_fs_sb.h 2004-09-12 19:14:37.000000000 +0400
275 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
276 int s_jquota_fmt; /* Format of quota to use */
281 #endif /* _LINUX_EXT3_FS_SB */