1 diff -urp linux-2.6.5-7.282.orig/fs/ext3/ialloc.c linux-2.6.5-7.282/fs/ext3/ialloc.c
2 --- linux-2.6.5-7.282.orig/fs/ext3/ialloc.c 2006-08-30 17:12:13.000000000 +0300
3 +++ linux-2.6.5-7.282/fs/ext3/ialloc.c 2007-02-16 07:43:08.000000000 +0200
4 @@ -420,7 +420,8 @@ static int find_group_other(struct super
5 * For other inodes, search forward from the parent directory's block
6 * group to find a free inode.
8 -struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
9 +struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode,
12 struct super_block *sb;
13 struct buffer_head *bitmap_bh = NULL;
14 @@ -448,6 +449,41 @@ struct inode *ext3_new_inode(handle_t *h
19 + group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
20 + ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
23 + gdp = ext3_get_group_desc(sb, group, &bh2);
27 + bitmap_bh = read_inode_bitmap (sb, group);
31 + BUFFER_TRACE(bh, "get_write_access");
32 + err = ext3_journal_get_write_access(handle, bitmap_bh);
35 + if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
36 + ino, bitmap_bh->b_data)) {
37 + printk(KERN_ERR "goal inode %lu unavailable\n", goal);
38 + /* Oh well, we tried. */
39 + goto continue_allocation;
42 + BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
43 + err = ext3_journal_dirty_metadata(handle, bitmap_bh);
46 + /* We've shortcircuited the allocation system successfully,
47 + * now finish filling in the inode.
54 if (test_opt (sb, OLDALLOC))
55 group = find_group_dir(sb, dir);
56 diff -urp linux-2.6.5-7.282.orig/fs/ext3/ioctl.c linux-2.6.5-7.282/fs/ext3/ioctl.c
57 --- linux-2.6.5-7.282.orig/fs/ext3/ioctl.c 2006-08-30 17:12:13.000000000 +0300
58 +++ linux-2.6.5-7.282/fs/ext3/ioctl.c 2007-02-16 07:43:08.000000000 +0200
59 @@ -25,6 +25,31 @@ int ext3_ioctl (struct inode * inode, st
60 ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
63 + case EXT3_IOC_CREATE_INUM: {
65 + struct dentry *dchild, *dparent;
68 + dparent = list_entry(inode->i_dentry.next, struct dentry,
70 + snprintf(name, sizeof name, "%lu", arg);
71 + dchild = lookup_one_len(name, dparent, strlen(name));
72 + if (dchild->d_inode) {
73 + printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
74 + dparent->d_name.len, dparent->d_name.name, arg,
75 + dchild->d_inode->i_ino);
78 + dchild->d_fsdata = (void *)arg;
79 + rc = vfs_create(inode, dchild, 0644, NULL);
81 + printk(KERN_ERR "vfs_create: %d\n", rc);
82 + else if (dchild->d_inode->i_ino != arg)
88 case EXT3_IOC_GETFLAGS:
89 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
90 return put_user(flags, (int *) arg);
91 diff -urp linux-2.6.5-7.282.orig/fs/ext3/namei.c linux-2.6.5-7.282/fs/ext3/namei.c
92 --- linux-2.6.5-7.282.orig/fs/ext3/namei.c 2006-08-30 17:12:34.000000000 +0300
93 +++ linux-2.6.5-7.282/fs/ext3/namei.c 2007-02-16 07:46:13.000000000 +0200
94 @@ -144,6 +144,14 @@ struct dx_map_entry
98 +#define LVFS_DENTRY_PARAM_MAGIC 20070216UL
99 +struct lvfs_dentry_params
101 + unsigned long p_inum;
106 #ifdef CONFIG_EXT3_INDEX
107 static inline unsigned dx_get_block (struct dx_entry *entry);
108 static void dx_set_block (struct dx_entry *entry, unsigned value);
109 @@ -1625,6 +1633,20 @@ static int ext3_add_nondir(handle_t *han
113 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
114 + int mode, struct dentry *dentry)
116 + unsigned long inum = 0;
118 + if (dentry->d_fsdata != NULL) {
119 + struct lvfs_dentry_params *param = dentry->d_fsdata;
121 + if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
122 + inum = param->p_inum;
124 + return ext3_new_inode(handle, dir, mode, inum);
128 * By the time this is called, we already have created
129 * the directory cache entry for the new file, but it
130 @@ -1649,7 +1671,7 @@ retry:
134 - inode = ext3_new_inode (handle, dir, mode);
135 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
136 err = PTR_ERR(inode);
137 if (!IS_ERR(inode)) {
138 inode->i_op = &ext3_file_inode_operations;
139 @@ -1682,7 +1704,7 @@ retry:
143 - inode = ext3_new_inode (handle, dir, mode);
144 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
145 err = PTR_ERR(inode);
146 if (!IS_ERR(inode)) {
147 init_special_inode(inode, inode->i_mode, rdev);
148 @@ -1718,7 +1740,7 @@ retry:
152 - inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
153 + inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
154 err = PTR_ERR(inode);
157 @@ -2113,7 +2135,7 @@ retry:
161 - inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
162 + inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
163 err = PTR_ERR(inode);
166 diff -urp linux-2.6.5-7.282.orig/include/linux/ext3_fs.h linux-2.6.5-7.282/include/linux/ext3_fs.h
167 --- linux-2.6.5-7.282.orig/include/linux/ext3_fs.h 2006-08-30 17:12:13.000000000 +0300
168 +++ linux-2.6.5-7.282/include/linux/ext3_fs.h 2007-02-16 07:43:08.000000000 +0200
169 @@ -203,6 +203,7 @@ struct ext3_group_desc
170 #define EXT3_IOC_SETFLAGS _IOW('f', 2, long)
171 #define EXT3_IOC_GETVERSION _IOR('f', 3, long)
172 #define EXT3_IOC_SETVERSION _IOW('f', 4, long)
173 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
174 #define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long)
175 #define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long)
176 #ifdef CONFIG_JBD_DEBUG
177 @@ -712,7 +713,8 @@ extern int ext3fs_dirhash(const char *na
178 dx_hash_info *hinfo);
181 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
182 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
184 extern void ext3_free_inode (handle_t *, struct inode *);
185 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
186 extern unsigned long ext3_count_free_inodes (struct super_block *);
187 @@ -797,4 +799,5 @@ extern struct inode_operations ext3_fast
189 #endif /* __KERNEL__ */
191 +#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
192 #endif /* _LINUX_EXT3_FS_H */