hmm...Take a look at fs/read_write.c. There are calls to dnotify_parent in all file operation functions. There is a comment in fs/dnotify.c which says that dnotify_parent is "hopelessly wrong, but unfixable without API changes". Another good reason for a new file change notification api...
#ln tree1/sub/dir/file tree2/sub/dir/file
#watch_tree tree1 &
#do_something_to tree2/sub/dir/file
A dnotify can potentially know about open, chown, chmod,
utimes and possibly link of the files by watching the paths
and cwd; meaning it won't know about alternate paths. How
is it to know about read, write, fchown, fchmod and
truncate?
Perhaps someone else has a more fertile imagination butWhats wrong with that? You would just have to know the inode numbers of all directories in the subtree you are interested in. Then you can do a really fast inode->name translation using a hashtable or something. At least it is much more lightweight than having to open all directories :-)
short of looking up all the file inode numbers of the tree
in question and watching that whole list this sounds futile.