1 diff -pur linux-2.6.9-full.mid/fs/ext3/ialloc.c linux-2.6.9-full/fs/ext3/ialloc.c
2 --- linux-2.6.9-full.mid/fs/ext3/ialloc.c 2008-04-16 13:49:22.000000000 +0800
3 +++ linux-2.6.9-full/fs/ext3/ialloc.c 2008-04-16 15:26:40.000000000 +0800
4 @@ -440,6 +440,9 @@ struct inode *ext3_new_inode(handle_t *h
5 if (!dir || !dir->i_nlink)
6 return ERR_PTR(-EPERM);
8 + if (ext3_max_dir_size > 0 && i_size_read(dir) >= ext3_max_dir_size)
9 + return ERR_PTR(-EFBIG);
12 inode = new_inode(sb);
14 diff -pur linux-2.6.9-full.mid/fs/ext3/super.c linux-2.6.9-full/fs/ext3/super.c
15 --- linux-2.6.9-full.mid/fs/ext3/super.c 2008-05-06 16:07:23.000000000 +0800
16 +++ linux-2.6.9-full/fs/ext3/super.c 2008-05-12 02:05:36.000000000 +0800
17 @@ -2610,6 +2610,53 @@ static struct file_system_type ext3_fs_t
18 .fs_flags = FS_REQUIRES_DEV,
22 + * max directory size tunable
24 +#define EXT3_DEFAULT_MAX_DIR_SIZE 0
25 +#define EXT3_MAX_DIR_SIZE_NAME "max_dir_size"
27 +unsigned long ext3_max_dir_size;
29 +static int ext3_max_dir_size_read(char *page, char **start, off_t off,
30 + int count, int *eof, void *data)
38 + len = sprintf(page, "%lu\n", ext3_max_dir_size);
43 +static int ext3_max_dir_size_write(struct file *file, const char *buffer,
44 + unsigned long count, void *data)
47 + unsigned long value;
50 + if (count >= sizeof(str)) {
51 + printk(KERN_ERR "EXT3-fs: %s string too long, max %u bytes\n",
52 + EXT3_MAX_DIR_SIZE_NAME, (int)sizeof(str));
56 + if (copy_from_user(str, buffer, count))
59 + value = simple_strtol(str, &end, 0);
63 + ext3_max_dir_size = value;
68 #define EXT3_ROOT "ext3"
69 struct proc_dir_entry *proc_root_ext3;
71 @@ -2628,8 +2675,22 @@ int __init init_ext3_proc(void)
75 + proc = create_proc_entry(EXT3_MAX_DIR_SIZE_NAME,
76 + S_IFREG | S_IRUGO | S_IWUSR, proc_root_ext3);
78 + printk(KERN_ERR "EXT3-fs: Unable to create %s/%s\n",
79 + EXT3_ROOT, EXT3_MAX_DIR_SIZE_NAME);
85 + proc->read_proc = ext3_max_dir_size_read;
86 + proc->write_proc = ext3_max_dir_size_write;
90 + remove_proc_entry(EXT3_ROOT, proc_root_fs);
94 @@ -2639,6 +2700,7 @@ out:
95 void exit_ext3_proc(void)
98 + remove_proc_entry(EXT3_MAX_DIR_SIZE_NAME, proc_root_ext3);
99 remove_proc_entry(EXT3_ROOT, proc_root_fs);
102 diff -pur linux-2.6.9-full.mid/include/linux/ext3_fs.h linux-2.6.9-full/include/linux/ext3_fs.h
103 --- linux-2.6.9-full.mid/include/linux/ext3_fs.h 2008-04-16 14:02:18.000000000 +0800
104 +++ linux-2.6.9-full/include/linux/ext3_fs.h 2008-04-15 00:59:38.000000000 +0800
105 @@ -854,6 +854,8 @@ extern struct proc_dir_entry *proc_root_
106 extern int __init init_ext3_proc(void);
107 extern void exit_ext3_proc(void);
109 +extern unsigned long ext3_max_dir_size;
111 extern void ext3_error (struct super_block *, const char *, const char *, ...)
112 __attribute__ ((format (printf, 3, 4)));
113 extern void __ext3_std_error (struct super_block *, const char *, int);