xref: /linux/include/uapi/linux/inotify.h (revision 100c85421b52e41269ada88f7d71a6b8a06c7a11)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * Inode based directory notification for Linux
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright (C) 2005 John McCutchan
6607ca46eSDavid Howells  */
7607ca46eSDavid Howells 
8607ca46eSDavid Howells #ifndef _UAPI_LINUX_INOTIFY_H
9607ca46eSDavid Howells #define _UAPI_LINUX_INOTIFY_H
10607ca46eSDavid Howells 
11607ca46eSDavid Howells /* For O_CLOEXEC and O_NONBLOCK */
12607ca46eSDavid Howells #include <linux/fcntl.h>
13607ca46eSDavid Howells #include <linux/types.h>
14607ca46eSDavid Howells 
15607ca46eSDavid Howells /*
16607ca46eSDavid Howells  * struct inotify_event - structure read from the inotify device for each event
17607ca46eSDavid Howells  *
18607ca46eSDavid Howells  * When you are watching a directory, you will receive the filename for events
19607ca46eSDavid Howells  * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
20607ca46eSDavid Howells  */
21607ca46eSDavid Howells struct inotify_event {
22607ca46eSDavid Howells 	__s32		wd;		/* watch descriptor */
23607ca46eSDavid Howells 	__u32		mask;		/* watch mask */
24607ca46eSDavid Howells 	__u32		cookie;		/* cookie to synchronize two events */
25607ca46eSDavid Howells 	__u32		len;		/* length (including nulls) of name */
2694dfc73eSGustavo A. R. Silva 	char		name[];	/* stub for possible name */
27607ca46eSDavid Howells };
28607ca46eSDavid Howells 
29607ca46eSDavid Howells /* the following are legal, implemented events that user-space can watch for */
30607ca46eSDavid Howells #define IN_ACCESS		0x00000001	/* File was accessed */
31607ca46eSDavid Howells #define IN_MODIFY		0x00000002	/* File was modified */
32607ca46eSDavid Howells #define IN_ATTRIB		0x00000004	/* Metadata changed */
33*e2255550SVicki Pfau #define IN_CLOSE_WRITE		0x00000008	/* Writable file was closed */
34*e2255550SVicki Pfau #define IN_CLOSE_NOWRITE	0x00000010	/* Unwritable file closed */
35607ca46eSDavid Howells #define IN_OPEN			0x00000020	/* File was opened */
36607ca46eSDavid Howells #define IN_MOVED_FROM		0x00000040	/* File was moved from X */
37607ca46eSDavid Howells #define IN_MOVED_TO		0x00000080	/* File was moved to Y */
38607ca46eSDavid Howells #define IN_CREATE		0x00000100	/* Subfile was created */
39607ca46eSDavid Howells #define IN_DELETE		0x00000200	/* Subfile was deleted */
40607ca46eSDavid Howells #define IN_DELETE_SELF		0x00000400	/* Self was deleted */
41607ca46eSDavid Howells #define IN_MOVE_SELF		0x00000800	/* Self was moved */
42607ca46eSDavid Howells 
43607ca46eSDavid Howells /* the following are legal events.  they are sent as needed to any watch */
44607ca46eSDavid Howells #define IN_UNMOUNT		0x00002000	/* Backing fs was unmounted */
45607ca46eSDavid Howells #define IN_Q_OVERFLOW		0x00004000	/* Event queued overflowed */
46607ca46eSDavid Howells #define IN_IGNORED		0x00008000	/* File was ignored */
47607ca46eSDavid Howells 
48607ca46eSDavid Howells /* helper events */
49607ca46eSDavid Howells #define IN_CLOSE		(IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
50607ca46eSDavid Howells #define IN_MOVE			(IN_MOVED_FROM | IN_MOVED_TO) /* moves */
51607ca46eSDavid Howells 
52607ca46eSDavid Howells /* special flags */
53607ca46eSDavid Howells #define IN_ONLYDIR		0x01000000	/* only watch the path if it is a directory */
54607ca46eSDavid Howells #define IN_DONT_FOLLOW		0x02000000	/* don't follow a sym link */
55607ca46eSDavid Howells #define IN_EXCL_UNLINK		0x04000000	/* exclude events on unlinked objects */
564d97f7d5SHenry Wilson #define IN_MASK_CREATE		0x10000000	/* only create watches */
57607ca46eSDavid Howells #define IN_MASK_ADD		0x20000000	/* add to the mask of an already existing watch */
58607ca46eSDavid Howells #define IN_ISDIR		0x40000000	/* event occurred against dir */
59607ca46eSDavid Howells #define IN_ONESHOT		0x80000000	/* only send event once */
60607ca46eSDavid Howells 
61607ca46eSDavid Howells /*
62607ca46eSDavid Howells  * All of the events - we build the list by hand so that we can add flags in
63607ca46eSDavid Howells  * the future and not break backward compatibility.  Apps will get only the
64607ca46eSDavid Howells  * events that they originally wanted.  Be sure to add new events here!
65607ca46eSDavid Howells  */
66607ca46eSDavid Howells #define IN_ALL_EVENTS	(IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
67607ca46eSDavid Howells 			 IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
68607ca46eSDavid Howells 			 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
69607ca46eSDavid Howells 			 IN_MOVE_SELF)
70607ca46eSDavid Howells 
71607ca46eSDavid Howells /* Flags for sys_inotify_init1.  */
72607ca46eSDavid Howells #define IN_CLOEXEC O_CLOEXEC
73607ca46eSDavid Howells #define IN_NONBLOCK O_NONBLOCK
74607ca46eSDavid Howells 
75e1603b6eSKirill Tkhai /*
76e1603b6eSKirill Tkhai  * ioctl numbers: inotify uses 'I' prefix for all ioctls,
77e1603b6eSKirill Tkhai  * except historical FIONREAD, which is based on 'T'.
78e1603b6eSKirill Tkhai  *
79e1603b6eSKirill Tkhai  * INOTIFY_IOC_SETNEXTWD: set desired number of next created
80e1603b6eSKirill Tkhai  * watch descriptor.
81e1603b6eSKirill Tkhai  */
82e1603b6eSKirill Tkhai #define INOTIFY_IOC_SETNEXTWD	_IOW('I', 0, __s32)
83607ca46eSDavid Howells 
84607ca46eSDavid Howells #endif /* _UAPI_LINUX_INOTIFY_H */
85