diff options
Diffstat (limited to 'man7/inotify.7')
-rw-r--r-- | man7/inotify.7 | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/man7/inotify.7 b/man7/inotify.7 index 73a6ab0..51faaaa 100644 --- a/man7/inotify.7 +++ b/man7/inotify.7 @@ -3,7 +3,7 @@ .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" -.TH inotify 7 2023-07-08 "Linux man-pages 6.05.01" +.TH inotify 7 2023-10-31 "Linux man-pages 6.7" .SH NAME inotify \- monitoring filesystem events .SH DESCRIPTION @@ -14,7 +14,7 @@ Inotify can be used to monitor individual files, or to monitor directories. When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory. -.PP +.P The following system calls are used with this API: .IP \[bu] 3 .BR inotify_init (2) @@ -56,7 +56,7 @@ instance have been closed (using the underlying object and its resources are freed for reuse by the kernel; all associated watches are automatically freed. -.PP +.P With careful programming, an application can use inotify to efficiently monitor and cache the state of a set of filesystem objects. @@ -78,11 +78,11 @@ in which case the call fails with the error .BR EINTR ; see .BR signal (7)). -.PP +.P Each successful .BR read (2) returns a buffer containing one or more of the following structures: -.PP +.P .in +4n .EX struct inotify_event { @@ -99,15 +99,15 @@ struct inotify_event { }; .EE .in -.PP +.P .I wd identifies the watch for which this event occurs. It is one of the watch descriptors returned by a previous call to .BR inotify_add_watch (2). -.PP +.P .I mask contains bits that describe the event that occurred (see below). -.PP +.P .I cookie is a unique integer that connects related events. Currently, this is used only for rename events, and @@ -119,7 +119,7 @@ events to be connected by the application. For all other event types, .I cookie is set to 0. -.PP +.P The .I name field is present only when an event is returned @@ -128,7 +128,7 @@ it identifies the filename within the watched directory. This filename is null-terminated, and may include further null bytes (\[aq]\e0\[aq]) to align subsequent reads to a suitable address boundary. -.PP +.P The .I len field counts all of the bytes in @@ -138,7 +138,7 @@ the length of each .I inotify_event structure is thus .IR "sizeof(struct inotify_event)+len" . -.PP +.P The behavior when the buffer given to .BR read (2) is too small to return information about the next event depends @@ -149,13 +149,13 @@ returns 0; since Linux 2.6.21, fails with the error .BR EINVAL . Specifying a buffer of size -.PP +.P .in +4n .EX sizeof(struct inotify_event) + NAME_MAX + 1 .EE .in -.PP +.P will be sufficient to read at least one event. .SS inotify events The @@ -252,12 +252,12 @@ when a file is renamed. .BR IN_OPEN " (*)" File or directory was opened. .RE -.PP +.P Inotify monitoring is inode-based: when monitoring a file (but not when monitoring the directory containing a file), an event can be generated for activity on any link to the file (in the same or a different directory). -.PP +.P When monitoring a directory: .IP \[bu] 3 the events marked above with an asterisk (*) can occur both @@ -265,19 +265,19 @@ for the directory itself and for objects inside the directory; and .IP \[bu] the events marked with a plus sign (+) occur only for objects inside the directory (not for the directory itself). -.PP +.P .IR Note : when monitoring a directory, events are not generated for the files inside the directory when the events are performed via a pathname (i.e., a link) that lies outside the monitored directory. -.PP +.P When events are generated for objects inside a watched directory, the .I name field in the returned .I inotify_event structure identifies the name of the file within the directory. -.PP +.P The .B IN_ALL_EVENTS macro is defined as a bit mask of all of the above events. @@ -285,7 +285,7 @@ This macro can be used as the .I mask argument when calling .BR inotify_add_watch (2). -.PP +.P Two additional convenience macros are defined: .RS 4 .TP @@ -297,7 +297,7 @@ Equates to Equates to .BR "IN_CLOSE_WRITE | IN_CLOSE_NOWRITE" . .RE -.PP +.P The following further bits can be specified in .I mask when calling @@ -372,7 +372,7 @@ and multiple calls to .BR inotify_add_watch (2) without this flag may clobber existing watch masks. .RE -.PP +.P The following bits may be set in the .I mask field returned by @@ -449,7 +449,7 @@ events for both and .IR dir/myfile . .RE -.PP +.P Suppose an application is watching the directories .I dir1 and @@ -490,7 +490,7 @@ events will have the same .I cookie value. .RE -.PP +.P Suppose that .I dir1/xx and @@ -529,7 +529,7 @@ and an event for .IR dir1 . .RE -.PP +.P Suppose an application is watching the directory .I dir and (the empty) directory @@ -592,7 +592,7 @@ Inotify file descriptors can be monitored using and .BR epoll (7). When an event is available, the file descriptor indicates as readable. -.PP +.P Since Linux 2.6.25, signal-driven I/O notification is available for inotify file descriptors; see the discussion of @@ -621,7 +621,7 @@ and .B POLLIN is set in .IR si_band . -.PP +.P If successive output inotify events produced on the inotify file descriptor are identical (same .IR wd , @@ -634,13 +634,13 @@ older event has not yet been read (but see BUGS). This reduces the amount of kernel memory required for the event queue, but also means that an application can't use inotify to reliably count file events. -.PP +.P The events returned by reading from an inotify file descriptor form an ordered queue. Thus, for example, it is guaranteed that when renaming from one directory to another, events will be produced in the correct order on the inotify file descriptor. -.PP +.P The set of watch descriptors that is being monitored via an inotify file descriptor can be viewed via the entry for the inotify file descriptor in the process's @@ -661,7 +661,7 @@ In particular, there is no easy way for a process that is monitoring events via inotify to distinguish events that it triggers itself from those that are triggered by other processes. -.PP +.P Inotify reports only events that a user-space program triggers through the filesystem API. As a result, it does not catch remote events that occur @@ -674,28 +674,28 @@ Furthermore, various pseudo-filesystems such as and .I /dev/pts are not monitorable with inotify. -.PP +.P The inotify API does not report file accesses and modifications that may occur because of .BR mmap (2), .BR msync (2), and .BR munmap (2). -.PP +.P The inotify API identifies affected files by filename. However, by the time an application processes an inotify event, the filename may already have been deleted or renamed. -.PP +.P The inotify API identifies events via watch descriptors. It is the application's responsibility to cache a mapping (if one is needed) between watch descriptors and pathnames. Be aware that directory renamings may affect multiple cached pathnames. -.PP +.P Inotify monitoring of directories is not recursive: to monitor subdirectories under a directory, additional watches must be created. This can take a significant amount time for large directory trees. -.PP +.P If monitoring an entire directory subtree, and a new subdirectory is created in that tree or an existing directory is renamed into that tree, @@ -704,7 +704,7 @@ new files (and subdirectories) may already exist inside the subdirectory. Therefore, you may want to scan the contents of the subdirectory immediately after adding the watch (and, if desired, recursively add watches for any subdirectories that it contains). -.PP +.P Note that the event queue can overflow. In this case, events are lost. Robust applications should handle the possibility of @@ -716,7 +716,7 @@ approach is to close the inotify file descriptor, empty the cache, create a new inotify file descriptor, and then re-create watches and cache entries for the objects to be monitored.) -.PP +.P If a filesystem is mounted on top of a monitored directory, no event is generated, and no events are generated for objects immediately under the new mount point. @@ -733,7 +733,7 @@ event pair that is generated by .BR rename (2) can be matched up via their shared cookie value. However, the task of matching has some challenges. -.PP +.P These two events are usually consecutive in the event stream available when reading from the inotify file descriptor. However, this is not guaranteed. @@ -750,7 +750,7 @@ inserted into the queue: there may be a brief interval where the has appeared, but the .B IN_MOVED_TO has not. -.PP +.P Matching up the .B IN_MOVED_FROM and @@ -775,7 +775,7 @@ then those watch descriptors will be inconsistent with the watch descriptors in any pending events. (Re-creating the inotify file descriptor and rebuilding the cache may be useful to deal with this scenario.) -.PP +.P Applications should also allow for the possibility that the .B IN_MOVED_FROM event was the last event that could fit in the buffer @@ -803,7 +803,7 @@ calls to generate .B IN_MODIFY events. -.PP +.P .\" FIXME . kernel commit 611da04f7a31b2208e838be55a42c7a1310ae321 .\" implies that unmount events were buggy since Linux 2.6.11 to Linux 2.6.36 .\" @@ -811,7 +811,7 @@ Before Linux 2.6.16, the .B IN_ONESHOT .I mask flag does not work. -.PP +.P As originally designed and implemented, the .B IN_ONESHOT flag did not cause an @@ -821,7 +821,7 @@ However, as an unintended effect of other changes, since Linux 2.6.36, an .B IN_IGNORED event is generated in this case. -.PP +.P Before Linux 2.6.25, .\" commit 1c17d18e3775485bf1e0ce79575eb637a94494a2 the kernel code that was intended to coalesce successive identical events @@ -830,7 +830,7 @@ if the older had not yet been read) instead checked if the most recent event could be coalesced with the .I oldest unread event. -.PP +.P When a watch descriptor is removed by calling .BR inotify_rm_watch (2) (or because a watch file is deleted or the filesystem @@ -868,7 +868,7 @@ and waits for events of type .BR IN_CLOSE_NOWRITE , and .BR IN_CLOSE_WRITE . -.PP +.P The following output was recorded while editing the file .I /home/user/temp/foo and listing directory @@ -1095,6 +1095,6 @@ main(int argc, char* argv[]) .BR read (2), .BR stat (2), .BR fanotify (7) -.PP +.P .I Documentation/filesystems/inotify.txt in the Linux kernel source tree |