xref: /linux-6.15/include/uapi/linux/watch_queue.h (revision b580b936)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_LINUX_WATCH_QUEUE_H
3 #define _UAPI_LINUX_WATCH_QUEUE_H
4 
5 #include <linux/types.h>
6 #include <linux/fcntl.h>
7 
8 #define O_NOTIFICATION_PIPE	O_EXCL	/* Parameter to pipe2() selecting notification pipe */
9 
10 enum watch_notification_type {
11 	WATCH_TYPE_META		= 0,	/* Special record */
12 	WATCH_TYPE__NR		= 1
13 };
14 
15 enum watch_meta_notification_subtype {
16 	WATCH_META_REMOVAL_NOTIFICATION	= 0,	/* Watched object was removed */
17 	WATCH_META_LOSS_NOTIFICATION	= 1,	/* Data loss occurred */
18 };
19 
20 /*
21  * Notification record header.  This is aligned to 64-bits so that subclasses
22  * can contain __u64 fields.
23  */
24 struct watch_notification {
25 	__u32			type:24;	/* enum watch_notification_type */
26 	__u32			subtype:8;	/* Type-specific subtype (filterable) */
27 	__u32			info;
28 #define WATCH_INFO_LENGTH	0x0000007f	/* Length of record */
29 #define WATCH_INFO_LENGTH__SHIFT 0
30 #define WATCH_INFO_ID		0x0000ff00	/* ID of watchpoint */
31 #define WATCH_INFO_ID__SHIFT	8
32 #define WATCH_INFO_TYPE_INFO	0xffff0000	/* Type-specific info */
33 #define WATCH_INFO_TYPE_INFO__SHIFT 16
34 #define WATCH_INFO_FLAG_0	0x00010000	/* Type-specific info, flag bit 0 */
35 #define WATCH_INFO_FLAG_1	0x00020000	/* ... */
36 #define WATCH_INFO_FLAG_2	0x00040000
37 #define WATCH_INFO_FLAG_3	0x00080000
38 #define WATCH_INFO_FLAG_4	0x00100000
39 #define WATCH_INFO_FLAG_5	0x00200000
40 #define WATCH_INFO_FLAG_6	0x00400000
41 #define WATCH_INFO_FLAG_7	0x00800000
42 };
43 
44 
45 /*
46  * Extended watch removal notification.  This is used optionally if the type
47  * wants to indicate an identifier for the object being watched, if there is
48  * such.  This can be distinguished by the length.
49  *
50  * type -> WATCH_TYPE_META
51  * subtype -> WATCH_META_REMOVAL_NOTIFICATION
52  */
53 struct watch_notification_removal {
54 	struct watch_notification watch;
55 	__u64	id;		/* Type-dependent identifier */
56 };
57 
58 #endif /* _UAPI_LINUX_WATCH_QUEUE_H */
59