diff options
Diffstat (limited to 'fs/inotify.c')
| -rw-r--r-- | fs/inotify.c | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index e423bfe0c86f..54757be888b6 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
| @@ -29,8 +29,6 @@ | |||
| 29 | #include <linux/mount.h> | 29 | #include <linux/mount.h> |
| 30 | #include <linux/namei.h> | 30 | #include <linux/namei.h> |
| 31 | #include <linux/poll.h> | 31 | #include <linux/poll.h> |
| 32 | #include <linux/device.h> | ||
| 33 | #include <linux/miscdevice.h> | ||
| 34 | #include <linux/init.h> | 32 | #include <linux/init.h> |
| 35 | #include <linux/list.h> | 33 | #include <linux/list.h> |
| 36 | #include <linux/writeback.h> | 34 | #include <linux/writeback.h> |
| @@ -45,8 +43,8 @@ static kmem_cache_t *event_cachep; | |||
| 45 | 43 | ||
| 46 | static struct vfsmount *inotify_mnt; | 44 | static struct vfsmount *inotify_mnt; |
| 47 | 45 | ||
| 48 | /* These are configurable via /proc/sys/inotify */ | 46 | /* these are configurable via /proc/sys/fs/inotify/ */ |
| 49 | int inotify_max_user_devices; | 47 | int inotify_max_user_instances; |
| 50 | int inotify_max_user_watches; | 48 | int inotify_max_user_watches; |
| 51 | int inotify_max_queued_events; | 49 | int inotify_max_queued_events; |
| 52 | 50 | ||
| @@ -125,6 +123,47 @@ struct inotify_watch { | |||
| 125 | u32 mask; /* event mask for this watch */ | 123 | u32 mask; /* event mask for this watch */ |
| 126 | }; | 124 | }; |
| 127 | 125 | ||
| 126 | #ifdef CONFIG_SYSCTL | ||
| 127 | |||
| 128 | #include <linux/sysctl.h> | ||
| 129 | |||
| 130 | static int zero; | ||
| 131 | |||
| 132 | ctl_table inotify_table[] = { | ||
| 133 | { | ||
| 134 | .ctl_name = INOTIFY_MAX_USER_INSTANCES, | ||
| 135 | .procname = "max_user_instances", | ||
| 136 | .data = &inotify_max_user_instances, | ||
| 137 | .maxlen = sizeof(int), | ||
| 138 | .mode = 0644, | ||
| 139 | .proc_handler = &proc_dointvec_minmax, | ||
| 140 | .strategy = &sysctl_intvec, | ||
| 141 | .extra1 = &zero, | ||
| 142 | }, | ||
| 143 | { | ||
| 144 | .ctl_name = INOTIFY_MAX_USER_WATCHES, | ||
| 145 | .procname = "max_user_watches", | ||
| 146 | .data = &inotify_max_user_watches, | ||
| 147 | .maxlen = sizeof(int), | ||
| 148 | .mode = 0644, | ||
| 149 | .proc_handler = &proc_dointvec_minmax, | ||
| 150 | .strategy = &sysctl_intvec, | ||
| 151 | .extra1 = &zero, | ||
| 152 | }, | ||
| 153 | { | ||
| 154 | .ctl_name = INOTIFY_MAX_QUEUED_EVENTS, | ||
| 155 | .procname = "max_queued_events", | ||
| 156 | .data = &inotify_max_queued_events, | ||
| 157 | .maxlen = sizeof(int), | ||
| 158 | .mode = 0644, | ||
| 159 | .proc_handler = &proc_dointvec_minmax, | ||
| 160 | .strategy = &sysctl_intvec, | ||
| 161 | .extra1 = &zero | ||
| 162 | }, | ||
| 163 | { .ctl_name = 0 } | ||
| 164 | }; | ||
| 165 | #endif /* CONFIG_SYSCTL */ | ||
| 166 | |||
| 128 | static inline void get_inotify_dev(struct inotify_device *dev) | 167 | static inline void get_inotify_dev(struct inotify_device *dev) |
| 129 | { | 168 | { |
| 130 | atomic_inc(&dev->count); | 169 | atomic_inc(&dev->count); |
| @@ -842,7 +881,7 @@ asmlinkage long sys_inotify_init(void) | |||
| 842 | 881 | ||
| 843 | user = get_uid(current->user); | 882 | user = get_uid(current->user); |
| 844 | 883 | ||
| 845 | if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_devices)) { | 884 | if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_instances)) { |
| 846 | ret = -EMFILE; | 885 | ret = -EMFILE; |
| 847 | goto out_err; | 886 | goto out_err; |
| 848 | } | 887 | } |
| @@ -893,7 +932,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char *path, u32 mask) | |||
| 893 | 932 | ||
| 894 | dev = filp->private_data; | 933 | dev = filp->private_data; |
| 895 | 934 | ||
| 896 | ret = find_inode ((const char __user*)path, &nd); | 935 | ret = find_inode((const char __user*) path, &nd); |
| 897 | if (ret) | 936 | if (ret) |
| 898 | goto fput_and_out; | 937 | goto fput_and_out; |
| 899 | 938 | ||
| @@ -950,8 +989,9 @@ asmlinkage long sys_inotify_rm_watch(int fd, u32 wd) | |||
| 950 | if (!filp) | 989 | if (!filp) |
| 951 | return -EBADF; | 990 | return -EBADF; |
| 952 | dev = filp->private_data; | 991 | dev = filp->private_data; |
| 953 | ret = inotify_ignore (dev, wd); | 992 | ret = inotify_ignore(dev, wd); |
| 954 | fput(filp); | 993 | fput(filp); |
| 994 | |||
| 955 | return ret; | 995 | return ret; |
| 956 | } | 996 | } |
| 957 | 997 | ||
| @@ -979,7 +1019,7 @@ static int __init inotify_init(void) | |||
| 979 | inotify_mnt = kern_mount(&inotify_fs_type); | 1019 | inotify_mnt = kern_mount(&inotify_fs_type); |
| 980 | 1020 | ||
| 981 | inotify_max_queued_events = 8192; | 1021 | inotify_max_queued_events = 8192; |
| 982 | inotify_max_user_devices = 128; | 1022 | inotify_max_user_instances = 8; |
| 983 | inotify_max_user_watches = 8192; | 1023 | inotify_max_user_watches = 8192; |
| 984 | 1024 | ||
| 985 | atomic_set(&inotify_cookie, 0); | 1025 | atomic_set(&inotify_cookie, 0); |
| @@ -991,8 +1031,6 @@ static int __init inotify_init(void) | |||
| 991 | sizeof(struct inotify_kernel_event), | 1031 | sizeof(struct inotify_kernel_event), |
| 992 | 0, SLAB_PANIC, NULL, NULL); | 1032 | 0, SLAB_PANIC, NULL, NULL); |
| 993 | 1033 | ||
| 994 | printk(KERN_INFO "inotify syscall\n"); | ||
| 995 | |||
| 996 | return 0; | 1034 | return 0; |
| 997 | } | 1035 | } |
| 998 | 1036 | ||
