Re: [patch] add IN_ONLYDIR based errors in inotify_add_watch(2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Paul,

On 04/20/2018 10:28 AM, Paul Millar wrote:
Hi,

I noticed that it was undocumented how inotify_add_watch(2) behaves if IN_ONLYDIR is specified and the target is not a directory.

To discover this, I took the example code in inotify(7) and modified it to include the IN_ONLYDIR flag.  Running the code against an ordinary file, I saw the following output:


    paul@sparkplug:~/git/dCache (development/frontend-inotify-namespace)$ ./inotify-test README
     Press ENTER key to terminate.
     Cannot watch 'README'
     inotify_add_watch: Not a directory
     paul@sparkplug:~/git/dCache (development/frontend-inotify-namespace)$


My machine is "Debian GNU/Linux 9.4 (stretch)".  I imagine (but haven't tested) that the same errno is used on other distros.

I've included a patch that adds ENOTDIR as an additional error in the inotify_add_watch(2) man page.

Thanks. Patch applied.

I'm undecided whether or not the section in inotify(7) describing IN_ONLYDIR should also be updated to describe how non-directory targets are handled.

I think it's reasonable to do so, and I added the patch below.

Thanks for the patch and the report!

Cheers,

Michael

diff --git a/man7/inotify.7 b/man7/inotify.7
index 7e5a5b4df..85c05a9bc 100644
--- a/man7/inotify.7
+++ b/man7/inotify.7
@@ -358,7 +358,12 @@ watch list.
 .BR IN_ONLYDIR " (since Linux 2.6.15)"
 Watch
 .I pathname
-only if it is a directory.
+only if it is a directory;
+the error
+.B ENOTDIR
+results if
+.I pathname
+is not a directory.
 Using this flag provides an application with a race-free way of
 ensuring that the monitored object is a directory.
 .RE
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux