Commit d7d3ae66 authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Linus Torvalds

[PATCH] dnotify

The following patch makes directory notifications per thread group instead
of per process tree as they are now.  This means, in particular, that if
a child closes a file descriptor that has a directory open with notifies
enabled, the notification will not be removed.

Thanks to Andrea for the push in the right direction.
parent cbada281
/* /*
* Directory notifications for Linux. * Directory notifications for Linux.
* *
* Copyright (C) 2000 Stephen Rothwell * Copyright (C) 2000,2001,2002 Stephen Rothwell
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
...@@ -59,7 +59,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) ...@@ -59,7 +59,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
write_lock(&dn_lock); write_lock(&dn_lock);
prev = &inode->i_dnotify; prev = &inode->i_dnotify;
for (odn = *prev; odn != NULL; prev = &odn->dn_next, odn = *prev) for (odn = *prev; odn != NULL; prev = &odn->dn_next, odn = *prev)
if (odn->dn_filp == filp) if ((odn->dn_owner == current->files) && (odn->dn_filp == filp))
break; break;
if (odn != NULL) { if (odn != NULL) {
if (turning_off) { if (turning_off) {
...@@ -82,6 +82,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) ...@@ -82,6 +82,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
dn->dn_mask = arg; dn->dn_mask = arg;
dn->dn_fd = fd; dn->dn_fd = fd;
dn->dn_filp = filp; dn->dn_filp = filp;
dn->dn_owner = current->files;
inode->i_dnotify_mask |= arg & ~DN_MULTISHOT; inode->i_dnotify_mask |= arg & ~DN_MULTISHOT;
dn->dn_next = inode->i_dnotify; dn->dn_next = inode->i_dnotify;
inode->i_dnotify = dn; inode->i_dnotify = dn;
......
...@@ -13,6 +13,7 @@ struct dnotify_struct { ...@@ -13,6 +13,7 @@ struct dnotify_struct {
see linux/fcntl.h */ see linux/fcntl.h */
int dn_fd; int dn_fd;
struct file * dn_filp; struct file * dn_filp;
fl_owner_t dn_owner;
}; };
#define DNOTIFY_MAGIC 0x444E4F54 #define DNOTIFY_MAGIC 0x444E4F54
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment