1 fs/ext3/ialloc.c | 35 ++++++++++++++++++++++++++++++++++-
2 fs/ext3/ioctl.c | 25 +++++++++++++++++++++++++
3 fs/ext3/namei.c | 21 +++++++++++++++++----
4 include/linux/dcache.h | 5 +++++
5 include/linux/ext3_fs.h | 5 ++++-
6 5 files changed, 85 insertions(+), 6 deletions(-)
8 Index: linux-2.6.15/fs/ext3/ialloc.c
9 ===================================================================
10 --- linux-2.6.15.orig/fs/ext3/ialloc.c 2006-02-19 15:23:12.000000000 +0300
11 +++ linux-2.6.15/fs/ext3/ialloc.c 2006-02-21 00:26:52.000000000 +0300
12 @@ -420,7 +420,8 @@ static int find_group_other(struct super
13 * For other inodes, search forward from the parent directory's block
14 * group to find a free inode.
16 -struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
17 +struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode,
20 struct super_block *sb;
21 struct buffer_head *bitmap_bh = NULL;
22 @@ -448,6 +449,38 @@ struct inode *ext3_new_inode(handle_t *h
27 + group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
28 + ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
29 + gdp = ext3_get_group_desc(sb, group, &bh2);
32 + bitmap_bh = read_inode_bitmap (sb, group);
36 + BUFFER_TRACE(bh, "get_write_access");
37 + err = ext3_journal_get_write_access(handle, bitmap_bh);
40 + if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
41 + ino, bitmap_bh->b_data)) {
42 + printk(KERN_ERR "goal inode %lu unavailable\n", goal);
43 + /* Oh well, we tried. */
44 + goto continue_allocation;
47 + BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
48 + err = ext3_journal_dirty_metadata(handle, bitmap_bh);
51 + /* We've shortcircuited the allocation system successfully,
52 + * now finish filling in the inode.
59 if (test_opt (sb, OLDALLOC))
60 group = find_group_dir(sb, dir);
61 Index: linux-2.6.15/fs/ext3/ioctl.c
62 ===================================================================
63 --- linux-2.6.15.orig/fs/ext3/ioctl.c 2005-11-11 08:33:12.000000000 +0300
64 +++ linux-2.6.15/fs/ext3/ioctl.c 2006-02-21 00:26:52.000000000 +0300
65 @@ -25,6 +25,31 @@ int ext3_ioctl (struct inode * inode, st
66 ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
69 + case EXT3_IOC_CREATE_INUM: {
71 + struct dentry *dchild, *dparent;
74 + dparent = list_entry(inode->i_dentry.next, struct dentry,
76 + snprintf(name, sizeof name, "%lu", arg);
77 + dchild = lookup_one_len(name, dparent, strlen(name));
78 + if (dchild->d_inode) {
79 + printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
80 + dparent->d_name.len, dparent->d_name.name, arg,
81 + dchild->d_inode->i_ino);
84 + dchild->d_fsdata = (void *)arg;
85 + rc = vfs_create(inode, dchild, 0644, NULL);
87 + printk(KERN_ERR "vfs_create: %d\n", rc);
88 + else if (dchild->d_inode->i_ino != arg)
94 case EXT3_IOC_GETFLAGS:
95 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
96 return put_user(flags, (int __user *) arg);
97 Index: linux-2.6.15/fs/ext3/namei.c
98 ===================================================================
99 --- linux-2.6.15.orig/fs/ext3/namei.c 2006-02-19 15:23:12.000000000 +0300
100 +++ linux-2.6.15/fs/ext3/namei.c 2006-02-21 00:28:17.000000000 +0300
101 @@ -1631,6 +1631,16 @@ static int ext3_add_nondir(handle_t *han
105 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
106 + int mode, struct dentry *dentry)
108 + unsigned long inum = 0;
110 + if (dentry->d_fsdata != NULL)
111 + inum = (unsigned long) dentry->d_fsdata;
112 + return ext3_new_inode(handle, dir, mode, inum);
116 * By the time this is called, we already have created
117 * the directory cache entry for the new file, but it
118 @@ -1656,7 +1666,7 @@ retry:
122 - inode = ext3_new_inode (handle, dir, mode);
123 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
124 err = PTR_ERR(inode);
125 if (!IS_ERR(inode)) {
126 inode->i_op = &ext3_file_inode_operations;
127 @@ -1690,7 +1700,7 @@ retry:
131 - inode = ext3_new_inode (handle, dir, mode);
132 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
133 err = PTR_ERR(inode);
134 if (!IS_ERR(inode)) {
135 init_special_inode(inode, inode->i_mode, rdev);
136 @@ -1726,7 +1736,7 @@ retry:
140 - inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
141 + inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
142 err = PTR_ERR(inode);
145 @@ -2131,7 +2141,7 @@ retry:
149 - inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
150 + inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
151 err = PTR_ERR(inode);
154 Index: linux-2.6.15/include/linux/ext3_fs.h
155 ===================================================================
156 --- linux-2.6.15.orig/include/linux/ext3_fs.h 2005-11-11 08:33:12.000000000 +0300
157 +++ linux-2.6.15/include/linux/ext3_fs.h 2006-02-21 00:26:52.000000000 +0300
158 @@ -762,7 +762,8 @@ extern int ext3fs_dirhash(const char *na
159 dx_hash_info *hinfo);
162 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
163 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
165 extern void ext3_free_inode (handle_t *, struct inode *);
166 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
167 extern unsigned long ext3_count_free_inodes (struct super_block *);
168 @@ -844,4 +845,6 @@ extern struct inode_operations ext3_fast
170 #endif /* __KERNEL__ */
172 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
173 +#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
174 #endif /* _LINUX_EXT3_FS_H */