[patch] inotify 0.22 for 2.6.12-rc1-mm4
On Mon, 2005-04-04 at 16:02 -0400, Robert Love wrote: Greetings, Mr Morton. > Below, find inotify 0.22, against 2.6.12-rc1. > > This release introduces a conversion in our primary locking from > spinlocks to semaphores. Semaphores are a more natural fit for our > code, which synchronizes with user-space, thus we clean up a bit of code > with a net reduction of 63 lines. Also, I was able to remove the > GFP_ATOMIC allocation. > > I did this as a bit of an experiment, not to fix any specific problem, > and I now think it is the right way to go. > > This release also fixes a small bug in the coalescing code, which could > of mistakenly dropped a move event. We now verify that the cookies > match before coalescing. And a patch for 2.6.12-rc1-mm4. Robert Love 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 device node, not SIGIO. You open a single fd to the device node, 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) and Gamin (a FAM replacement). Signed-off-by: Robert Love <[EMAIL PROTECTED]> Documentation/filesystems/inotify.txt | 81 ++ fs/Kconfig| 13 fs/Makefile |1 fs/attr.c | 33 - fs/compat.c | 12 fs/file_table.c |3 fs/inode.c|6 fs/inotify.c | 979 ++ fs/namei.c| 30 - fs/open.c |6 fs/read_write.c | 15 include/linux/fs.h|6 include/linux/fsnotify.h | 228 +++ include/linux/inotify.h | 113 +++ include/linux/sched.h |4 kernel/user.c |4 16 files changed, 1478 insertions(+), 56 deletions(-) diff -urN linux-2.6.12-rc1-mm4/Documentation/filesystems/inotify.txt linux/Documentation/filesystems/inotify.txt --- linux-2.6.12-rc1-mm4/Documentation/filesystems/inotify.txt 1969-12-31 19:00:00.0 -0500 +++ linux/Documentation/filesystems/inotify.txt 2005-04-04 13:32:02.0 -0400 @@ -0,0 +1,81 @@ + inotify +a powerful yet simple file change notification system + + + +Document started 15 Mar 2005 by Robert Love <[EMAIL PROTECTED]> + +(i) User Interface + +Inotify is controlled by a device node, /dev/inotify. If you do not use udev, +this device may need to be created manually. First step, open it + + int dev_fd = open ("/dev/inotify", O_RDONLY); + +Change events are managed by "watches". A watch is an (object,mask) pair where +the object is a file or directory and the mask is a bitmask of one or more +inotify events that the application wishes to receive. See +for valid events. A watch is referenced by a watch descriptor, or wd. + +Watches are added via a file descriptor. + +Watches on a directory will return events on any files inside of the directory. + +Adding a watch is simple, + + /* 'wd' represents the watch on fd with mask */ + struct inotify_request req = { fd, mask }; + int wd = ioctl (dev_fd, INOTIFY_WATCH, ); + +You can add a large number of files via something like + + for each file to watch { + struct inotify_request req; + int file_fd; + + file_fd = open (file, O_RDONLY); + if (fd < 0) { + perror ("open"); + break; + } + + req.fd = file_fd; + req.mask = mask; + + wd = ioctl (dev_fd, INOTIFY_WATCH, ); + + close (fd); + } + +You can update an existing watch in the same manner, by passing in a new mask. + +An existing watch is removed via the INOTIFY_IGNORE ioctl, for example + + ioctl (dev_fd, INOTIFY_IGNORE, wd); + +Events are provided in the form of an inotify_event structure that is read(2) +from /dev/inotify. The filename is of dynamic
[patch] inotify 0.22 for 2.6.12-rc1-mm4
On Mon, 2005-04-04 at 16:02 -0400, Robert Love wrote: Greetings, Mr Morton. Below, find inotify 0.22, against 2.6.12-rc1. This release introduces a conversion in our primary locking from spinlocks to semaphores. Semaphores are a more natural fit for our code, which synchronizes with user-space, thus we clean up a bit of code with a net reduction of 63 lines. Also, I was able to remove the GFP_ATOMIC allocation. I did this as a bit of an experiment, not to fix any specific problem, and I now think it is the right way to go. This release also fixes a small bug in the coalescing code, which could of mistakenly dropped a move event. We now verify that the cookies match before coalescing. And a patch for 2.6.12-rc1-mm4. Robert Love 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 device node, not SIGIO. You open a single fd to the device node, 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) and Gamin (a FAM replacement). Signed-off-by: Robert Love [EMAIL PROTECTED] Documentation/filesystems/inotify.txt | 81 ++ fs/Kconfig| 13 fs/Makefile |1 fs/attr.c | 33 - fs/compat.c | 12 fs/file_table.c |3 fs/inode.c|6 fs/inotify.c | 979 ++ fs/namei.c| 30 - fs/open.c |6 fs/read_write.c | 15 include/linux/fs.h|6 include/linux/fsnotify.h | 228 +++ include/linux/inotify.h | 113 +++ include/linux/sched.h |4 kernel/user.c |4 16 files changed, 1478 insertions(+), 56 deletions(-) diff -urN linux-2.6.12-rc1-mm4/Documentation/filesystems/inotify.txt linux/Documentation/filesystems/inotify.txt --- linux-2.6.12-rc1-mm4/Documentation/filesystems/inotify.txt 1969-12-31 19:00:00.0 -0500 +++ linux/Documentation/filesystems/inotify.txt 2005-04-04 13:32:02.0 -0400 @@ -0,0 +1,81 @@ + inotify +a powerful yet simple file change notification system + + + +Document started 15 Mar 2005 by Robert Love [EMAIL PROTECTED] + +(i) User Interface + +Inotify is controlled by a device node, /dev/inotify. If you do not use udev, +this device may need to be created manually. First step, open it + + int dev_fd = open (/dev/inotify, O_RDONLY); + +Change events are managed by watches. A watch is an (object,mask) pair where +the object is a file or directory and the mask is a bitmask of one or more +inotify events that the application wishes to receive. See linux/inotify.h +for valid events. A watch is referenced by a watch descriptor, or wd. + +Watches are added via a file descriptor. + +Watches on a directory will return events on any files inside of the directory. + +Adding a watch is simple, + + /* 'wd' represents the watch on fd with mask */ + struct inotify_request req = { fd, mask }; + int wd = ioctl (dev_fd, INOTIFY_WATCH, req); + +You can add a large number of files via something like + + for each file to watch { + struct inotify_request req; + int file_fd; + + file_fd = open (file, O_RDONLY); + if (fd 0) { + perror (open); + break; + } + + req.fd = file_fd; + req.mask = mask; + + wd = ioctl (dev_fd, INOTIFY_WATCH, req); + + close (fd); + } + +You can update an existing watch in the same manner, by passing in a new mask. + +An existing watch is removed via the INOTIFY_IGNORE ioctl, for example + + ioctl (dev_fd, INOTIFY_IGNORE, wd); + +Events are provided in the form of an inotify_event structure that is read(2) +from /dev/inotify. The filename is of dynamic