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.7/fs/ext3/ialloc.c
9 ===================================================================
10 --- linux-2.6.7.orig/fs/ext3/ialloc.c 2005-03-24 00:27:43.282608616 +0800
11 +++ linux-2.6.7/fs/ext3/ialloc.c 2005-03-24 00:27:43.888516504 +0800
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;
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.7/fs/ext3/ioctl.c
62 ===================================================================
63 --- linux-2.6.7.orig/fs/ext3/ioctl.c 2004-06-16 13:19:13.000000000 +0800
64 +++ linux-2.6.7/fs/ext3/ioctl.c 2005-03-24 00:31:16.113253440 +0800
68 #include <linux/jbd.h>
69 +#include <linux/namei.h>
70 #include <linux/ext3_fs.h>
71 #include <linux/ext3_jbd.h>
72 #include <linux/time.h>
74 ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
77 + case EXT3_IOC_CREATE_INUM: {
79 + struct dentry *dchild, *dparent;
82 + dparent = list_entry(inode->i_dentry.next, struct dentry,
84 + snprintf(name, sizeof name, "%lu", arg);
85 + dchild = lookup_one_len(name, dparent, strlen(name));
86 + if (dchild->d_inode) {
87 + printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
88 + dparent->d_name.len, dparent->d_name.name, arg,
89 + dchild->d_inode->i_ino);
92 + dchild->d_fsdata = (void *)arg;
93 + rc = vfs_create(inode, dchild, 0644, NULL);
95 + printk(KERN_ERR "vfs_create: %d\n", rc);
96 + else if (dchild->d_inode->i_ino != arg)
102 case EXT3_IOC_GETFLAGS:
103 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
104 return put_user(flags, (int __user *) arg);
105 Index: linux-2.6.7/fs/ext3/namei.c
106 ===================================================================
107 --- linux-2.6.7.orig/fs/ext3/namei.c 2005-03-24 00:27:43.536570008 +0800
108 +++ linux-2.6.7/fs/ext3/namei.c 2005-03-24 00:27:43.893515744 +0800
109 @@ -1939,6 +1939,19 @@
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 dentry_params *param =
120 + (struct dentry_params *) dentry->d_fsdata;
121 + inum = param->p_inum;
123 + return ext3_new_inode(handle, dir, mode, inum);
127 * By the time this is called, we already have created
128 * the directory cache entry for the new file, but it
129 @@ -1963,7 +1976,7 @@
133 - inode = ext3_new_inode (handle, dir, mode);
134 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
135 err = PTR_ERR(inode);
136 if (!IS_ERR(inode)) {
137 inode->i_op = &ext3_file_inode_operations;
138 @@ -1994,7 +2007,7 @@
142 - inode = ext3_new_inode (handle, dir, mode);
143 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
144 err = PTR_ERR(inode);
145 if (!IS_ERR(inode)) {
146 init_special_inode(inode, inode->i_mode, rdev);
147 @@ -2027,7 +2040,7 @@
151 - inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
152 + inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
153 err = PTR_ERR(inode);
156 @@ -2439,7 +2452,7 @@
160 - inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
161 + inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
162 err = PTR_ERR(inode);
165 Index: linux-2.6.7/include/linux/ext3_fs.h
166 ===================================================================
167 --- linux-2.6.7.orig/include/linux/ext3_fs.h 2005-03-24 00:27:43.542569096 +0800
168 +++ linux-2.6.7/include/linux/ext3_fs.h 2005-03-24 00:27:43.893515744 +0800
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
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 *);
189 #endif /* __KERNEL__ */
191 +#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
192 #endif /* _LINUX_EXT3_FS_H */