diff options
author | Robert Love <rml@novell.com> | 2005-07-12 17:06:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-12 23:38:38 -0400 |
commit | 0eeca28300df110bd6ed54b31193c83b87921443 (patch) | |
tree | 7db42d8a18d80eca538f5b7d25e0532b8fa38b85 /kernel | |
parent | bd4c625c061c2a38568d0add3478f59172455159 (diff) |
[PATCH] inotify
inotify is intended to correct the deficiencies of dnotify, particularly
its inability to scale and its terrible user interface:
* dnotify requires the opening of one fd per each directory
that you intend to watch. This quickly results in too many
open files and pins removable media, preventing unmount.
* dnotify is directory-based. You only learn about changes to
directories. Sure, a change to a file in a directory affects
the directory, but you are then forced to keep a cache of
stat structures.
* dnotify's interface to user-space is awful. Signals?
inotify provides a more usable, simple, powerful solution to file change
notification:
* inotify's interface is a system call that returns a fd, not SIGIO.
You get a single fd, which is select()-able.
* inotify has an event that says "the filesystem that the item
you were watching is on was unmounted."
* inotify can watch directories or files.
Inotify is currently used by Beagle (a desktop search infrastructure),
Gamin (a FAM replacement), and other projects.
See Documentation/filesystems/inotify.txt.
Signed-off-by: Robert Love <rml@novell.com>
Cc: John McCutchan <ttb@tentacle.dhs.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sys_ni.c | 3 | ||||
-rw-r--r-- | kernel/sysctl.c | 43 | ||||
-rw-r--r-- | kernel/user.c | 4 |
3 files changed, 49 insertions, 1 deletions
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 29196ce9b40f..42b40ae5eada 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c | |||
@@ -80,6 +80,9 @@ cond_syscall(sys_keyctl); | |||
80 | cond_syscall(compat_sys_keyctl); | 80 | cond_syscall(compat_sys_keyctl); |
81 | cond_syscall(compat_sys_socketcall); | 81 | cond_syscall(compat_sys_socketcall); |
82 | cond_syscall(sys_set_zone_reclaim); | 82 | cond_syscall(sys_set_zone_reclaim); |
83 | cond_syscall(sys_inotify_init); | ||
84 | cond_syscall(sys_inotify_add_watch); | ||
85 | cond_syscall(sys_inotify_rm_watch); | ||
83 | 86 | ||
84 | /* arch-specific weak syscall entries */ | 87 | /* arch-specific weak syscall entries */ |
85 | cond_syscall(sys_pciconfig_read); | 88 | cond_syscall(sys_pciconfig_read); |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 270ee7fadbd8..b240e2cb86fc 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -67,6 +67,12 @@ extern int printk_ratelimit_jiffies; | |||
67 | extern int printk_ratelimit_burst; | 67 | extern int printk_ratelimit_burst; |
68 | extern int pid_max_min, pid_max_max; | 68 | extern int pid_max_min, pid_max_max; |
69 | 69 | ||
70 | #ifdef CONFIG_INOTIFY | ||
71 | extern int inotify_max_user_devices; | ||
72 | extern int inotify_max_user_watches; | ||
73 | extern int inotify_max_queued_events; | ||
74 | #endif | ||
75 | |||
70 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) | 76 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) |
71 | int unknown_nmi_panic; | 77 | int unknown_nmi_panic; |
72 | extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, | 78 | extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, |
@@ -218,6 +224,7 @@ static ctl_table root_table[] = { | |||
218 | .mode = 0555, | 224 | .mode = 0555, |
219 | .child = dev_table, | 225 | .child = dev_table, |
220 | }, | 226 | }, |
227 | |||
221 | { .ctl_name = 0 } | 228 | { .ctl_name = 0 } |
222 | }; | 229 | }; |
223 | 230 | ||
@@ -959,6 +966,40 @@ static ctl_table fs_table[] = { | |||
959 | .mode = 0644, | 966 | .mode = 0644, |
960 | .proc_handler = &proc_dointvec, | 967 | .proc_handler = &proc_dointvec, |
961 | }, | 968 | }, |
969 | #ifdef CONFIG_INOTIFY | ||
970 | { | ||
971 | .ctl_name = INOTIFY_MAX_USER_DEVICES, | ||
972 | .procname = "max_user_devices", | ||
973 | .data = &inotify_max_user_devices, | ||
974 | .maxlen = sizeof(int), | ||
975 | .mode = 0644, | ||
976 | .proc_handler = &proc_dointvec_minmax, | ||
977 | .strategy = &sysctl_intvec, | ||
978 | .extra1 = &zero, | ||
979 | }, | ||
980 | |||
981 | { | ||
982 | .ctl_name = INOTIFY_MAX_USER_WATCHES, | ||
983 | .procname = "max_user_watches", | ||
984 | .data = &inotify_max_user_watches, | ||
985 | .maxlen = sizeof(int), | ||
986 | .mode = 0644, | ||
987 | .proc_handler = &proc_dointvec_minmax, | ||
988 | .strategy = &sysctl_intvec, | ||
989 | .extra1 = &zero, | ||
990 | }, | ||
991 | |||
992 | { | ||
993 | .ctl_name = INOTIFY_MAX_QUEUED_EVENTS, | ||
994 | .procname = "max_queued_events", | ||
995 | .data = &inotify_max_queued_events, | ||
996 | .maxlen = sizeof(int), | ||
997 | .mode = 0644, | ||
998 | .proc_handler = &proc_dointvec_minmax, | ||
999 | .strategy = &sysctl_intvec, | ||
1000 | .extra1 = &zero | ||
1001 | }, | ||
1002 | #endif | ||
962 | { .ctl_name = 0 } | 1003 | { .ctl_name = 0 } |
963 | }; | 1004 | }; |
964 | 1005 | ||
@@ -968,7 +1009,7 @@ static ctl_table debug_table[] = { | |||
968 | 1009 | ||
969 | static ctl_table dev_table[] = { | 1010 | static ctl_table dev_table[] = { |
970 | { .ctl_name = 0 } | 1011 | { .ctl_name = 0 } |
971 | }; | 1012 | }; |
972 | 1013 | ||
973 | extern void init_irq_proc (void); | 1014 | extern void init_irq_proc (void); |
974 | 1015 | ||
diff --git a/kernel/user.c b/kernel/user.c index 734575d55769..89e562feb1b1 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
@@ -120,6 +120,10 @@ struct user_struct * alloc_uid(uid_t uid) | |||
120 | atomic_set(&new->processes, 0); | 120 | atomic_set(&new->processes, 0); |
121 | atomic_set(&new->files, 0); | 121 | atomic_set(&new->files, 0); |
122 | atomic_set(&new->sigpending, 0); | 122 | atomic_set(&new->sigpending, 0); |
123 | #ifdef CONFIG_INOTIFY | ||
124 | atomic_set(&new->inotify_watches, 0); | ||
125 | atomic_set(&new->inotify_devs, 0); | ||
126 | #endif | ||
123 | 127 | ||
124 | new->mq_bytes = 0; | 128 | new->mq_bytes = 0; |
125 | new->locked_shm = 0; | 129 | new->locked_shm = 0; |