1 Index: linux-2.6.9/fs/ext3/ialloc.c
2 ===================================================================
3 --- linux-2.6.9.orig/fs/ext3/ialloc.c 2007-03-13 00:47:22.000000000 +0100
4 +++ linux-2.6.9/fs/ext3/ialloc.c 2007-07-26 09:23:37.000000000 +0200
5 @@ -419,7 +419,8 @@ static int find_group_other(struct super
6 * For other inodes, search forward from the parent directory's block
7 * group to find a free inode.
9 -struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
10 +struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode,
13 struct super_block *sb;
14 struct buffer_head *bitmap_bh = NULL;
15 @@ -447,6 +448,41 @@ struct inode *ext3_new_inode(handle_t *h
20 + group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
21 + ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
24 + gdp = ext3_get_group_desc(sb, group, &bh2);
28 + bitmap_bh = read_inode_bitmap (sb, group);
32 + BUFFER_TRACE(bh, "get_write_access");
33 + err = ext3_journal_get_write_access(handle, bitmap_bh);
36 + if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
37 + ino, bitmap_bh->b_data)) {
38 + printk(KERN_ERR "goal inode %lu unavailable\n", goal);
39 + /* Oh well, we tried. */
40 + goto continue_allocation;
43 + BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
44 + err = ext3_journal_dirty_metadata(handle, bitmap_bh);
47 + /* We've shortcircuited the allocation system successfully,
48 + * now finish filling in the inode.
55 if (test_opt (sb, OLDALLOC))
56 group = find_group_dir(sb, dir);
57 Index: linux-2.6.9/fs/ext3/ioctl.c
58 ===================================================================
59 --- linux-2.6.9.orig/fs/ext3/ioctl.c 2007-03-13 00:47:22.000000000 +0100
60 +++ linux-2.6.9/fs/ext3/ioctl.c 2007-07-26 09:25:24.000000000 +0200
62 #include <linux/ext3_jbd.h>
63 #include <linux/time.h>
64 #include <asm/uaccess.h>
65 +#include <linux/namei.h>
68 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
69 @@ -25,6 +26,31 @@ int ext3_ioctl (struct inode * inode, st
70 ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
73 + case EXT3_IOC_CREATE_INUM: {
75 + struct dentry *dchild, *dparent;
78 + dparent = list_entry(inode->i_dentry.next, struct dentry,
80 + snprintf(name, sizeof name, "%lu", arg);
81 + dchild = lookup_one_len(name, dparent, strlen(name));
82 + if (dchild->d_inode) {
83 + printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
84 + dparent->d_name.len, dparent->d_name.name, arg,
85 + dchild->d_inode->i_ino);
88 + dchild->d_fsdata = (void *)arg;
89 + rc = vfs_create(inode, dchild, 0644, NULL);
91 + printk(KERN_ERR "vfs_create: %d\n", rc);
92 + else if (dchild->d_inode->i_ino != arg)
98 case EXT3_IOC_GETFLAGS:
99 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
100 return put_user(flags, (int __user *) arg);
101 Index: linux-2.6.9/fs/ext3/namei.c
102 ===================================================================
103 --- linux-2.6.9.orig/fs/ext3/namei.c 2007-03-13 00:47:27.000000000 +0100
104 +++ linux-2.6.9/fs/ext3/namei.c 2007-07-26 09:23:37.000000000 +0200
105 @@ -97,6 +97,7 @@ struct dx_entry
111 * dx_root_info is laid out so that if it should somehow get overlaid by a
112 * dirent the two low bits of the hash version will be zero. Therefore, the
113 @@ -141,6 +142,14 @@ struct dx_map_entry
117 +#define LVFS_DENTRY_PARAM_MAGIC 20070216UL
118 +struct lvfs_dentry_params
120 + unsigned long p_inum;
125 #ifdef CONFIG_EXT3_INDEX
126 static inline unsigned dx_get_block (struct dx_entry *entry);
127 static void dx_set_block (struct dx_entry *entry, unsigned value);
128 @@ -1633,6 +1642,20 @@ static int ext3_add_nondir(handle_t *han
132 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
133 + int mode, struct dentry *dentry)
135 + unsigned long inum = 0;
137 + if (dentry->d_fsdata != NULL) {
138 + struct lvfs_dentry_params *param = dentry->d_fsdata;
140 + if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
141 + inum = param->p_inum;
143 + return ext3_new_inode(handle, dir, mode, inum);
147 * By the time this is called, we already have created
148 * the directory cache entry for the new file, but it
149 @@ -1658,7 +1681,7 @@ retry:
153 - inode = ext3_new_inode (handle, dir, mode);
154 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
155 err = PTR_ERR(inode);
156 if (!IS_ERR(inode)) {
157 inode->i_op = &ext3_file_inode_operations;
158 @@ -1692,7 +1715,7 @@ retry:
162 - inode = ext3_new_inode (handle, dir, mode);
163 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
164 err = PTR_ERR(inode);
165 if (!IS_ERR(inode)) {
166 init_special_inode(inode, inode->i_mode, rdev);
167 @@ -1728,7 +1751,7 @@ retry:
171 - inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
172 + inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
173 err = PTR_ERR(inode);
176 @@ -2133,7 +2156,7 @@ retry:
180 - inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
181 + inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
182 err = PTR_ERR(inode);
185 Index: linux-2.6.9/include/linux/ext3_fs.h
186 ===================================================================
187 --- linux-2.6.9.orig/include/linux/ext3_fs.h 2007-03-13 00:47:22.000000000 +0100
188 +++ linux-2.6.9/include/linux/ext3_fs.h 2007-07-26 09:23:37.000000000 +0200
189 @@ -741,7 +741,8 @@ extern int ext3fs_dirhash(const char *na
190 dx_hash_info *hinfo);
193 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
194 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
196 extern void ext3_free_inode (handle_t *, struct inode *);
197 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
198 extern unsigned long ext3_count_free_inodes (struct super_block *);
199 @@ -833,4 +834,6 @@ extern struct inode_operations ext3_fast
201 #endif /* __KERNEL__ */
203 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
204 +#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
205 #endif /* _LINUX_EXT3_FS_H */