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 #include <linux/ioctl.h> 8 9 #define O_NOTIFICATION_PIPE O_EXCL /* Parameter to pipe2() selecting notification pipe */ 10 11 #define IOC_WATCH_QUEUE_SET_SIZE _IO('W', 0x60) /* Set the size in pages */ 12 #define IOC_WATCH_QUEUE_SET_FILTER _IO('W', 0x61) /* Set the filter */ 13 14 enum watch_notification_type { 15 WATCH_TYPE_META = 0, /* Special record */ 16 WATCH_TYPE__NR = 1 17 }; 18 19 enum watch_meta_notification_subtype { 20 WATCH_META_REMOVAL_NOTIFICATION = 0, /* Watched object was removed */ 21 WATCH_META_LOSS_NOTIFICATION = 1, /* Data loss occurred */ 22 }; 23 24 /* 25 * Notification record header. This is aligned to 64-bits so that subclasses 26 * can contain __u64 fields. 27 */ 28 struct watch_notification { 29 __u32 type:24; /* enum watch_notification_type */ 30 __u32 subtype:8; /* Type-specific subtype (filterable) */ 31 __u32 info; 32 #define WATCH_INFO_LENGTH 0x0000007f /* Length of record */ 33 #define WATCH_INFO_LENGTH__SHIFT 0 34 #define WATCH_INFO_ID 0x0000ff00 /* ID of watchpoint */ 35 #define WATCH_INFO_ID__SHIFT 8 36 #define WATCH_INFO_TYPE_INFO 0xffff0000 /* Type-specific info */ 37 #define WATCH_INFO_TYPE_INFO__SHIFT 16 38 #define WATCH_INFO_FLAG_0 0x00010000 /* Type-specific info, flag bit 0 */ 39 #define WATCH_INFO_FLAG_1 0x00020000 /* ... */ 40 #define WATCH_INFO_FLAG_2 0x00040000 41 #define WATCH_INFO_FLAG_3 0x00080000 42 #define WATCH_INFO_FLAG_4 0x00100000 43 #define WATCH_INFO_FLAG_5 0x00200000 44 #define WATCH_INFO_FLAG_6 0x00400000 45 #define WATCH_INFO_FLAG_7 0x00800000 46 }; 47 48 /* 49 * Notification filtering rules (IOC_WATCH_QUEUE_SET_FILTER). 50 */ 51 struct watch_notification_type_filter { 52 __u32 type; /* Type to apply filter to */ 53 __u32 info_filter; /* Filter on watch_notification::info */ 54 __u32 info_mask; /* Mask of relevant bits in info_filter */ 55 __u32 subtype_filter[8]; /* Bitmask of subtypes to filter on */ 56 }; 57 58 struct watch_notification_filter { 59 __u32 nr_filters; /* Number of filters */ 60 __u32 __reserved; /* Must be 0 */ 61 struct watch_notification_type_filter filters[]; 62 }; 63 64 65 /* 66 * Extended watch removal notification. This is used optionally if the type 67 * wants to indicate an identifier for the object being watched, if there is 68 * such. This can be distinguished by the length. 69 * 70 * type -> WATCH_TYPE_META 71 * subtype -> WATCH_META_REMOVAL_NOTIFICATION 72 */ 73 struct watch_notification_removal { 74 struct watch_notification watch; 75 __u64 id; /* Type-dependent identifier */ 76 }; 77 78 #endif /* _UAPI_LINUX_WATCH_QUEUE_H */ 79