1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _UAPI_LINUX_WATCH_QUEUE_H 2 #ifndef _UAPI_LINUX_WATCH_QUEUE_H 3 #define _UAPI_LINUX_WATCH_QUEUE_H 3 #define _UAPI_LINUX_WATCH_QUEUE_H 4 4 5 #include <linux/types.h> 5 #include <linux/types.h> 6 #include <linux/fcntl.h> 6 #include <linux/fcntl.h> 7 #include <linux/ioctl.h> 7 #include <linux/ioctl.h> 8 8 9 #define O_NOTIFICATION_PIPE O_EXCL /* Par 9 #define O_NOTIFICATION_PIPE O_EXCL /* Parameter to pipe2() selecting notification pipe */ 10 10 11 #define IOC_WATCH_QUEUE_SET_SIZE _IO('W 11 #define IOC_WATCH_QUEUE_SET_SIZE _IO('W', 0x60) /* Set the size in pages */ 12 #define IOC_WATCH_QUEUE_SET_FILTER _IO('W 12 #define IOC_WATCH_QUEUE_SET_FILTER _IO('W', 0x61) /* Set the filter */ 13 13 14 enum watch_notification_type { 14 enum watch_notification_type { 15 WATCH_TYPE_META = 0, /* Spe 15 WATCH_TYPE_META = 0, /* Special record */ 16 WATCH_TYPE_KEY_NOTIFY = 1, /* Key 16 WATCH_TYPE_KEY_NOTIFY = 1, /* Key change event notification */ 17 WATCH_TYPE__NR = 2 17 WATCH_TYPE__NR = 2 18 }; 18 }; 19 19 20 enum watch_meta_notification_subtype { 20 enum watch_meta_notification_subtype { 21 WATCH_META_REMOVAL_NOTIFICATION = 0, 21 WATCH_META_REMOVAL_NOTIFICATION = 0, /* Watched object was removed */ 22 WATCH_META_LOSS_NOTIFICATION = 1, 22 WATCH_META_LOSS_NOTIFICATION = 1, /* Data loss occurred */ 23 }; 23 }; 24 24 25 /* 25 /* 26 * Notification record header. This is aligne 26 * Notification record header. This is aligned to 64-bits so that subclasses 27 * can contain __u64 fields. 27 * can contain __u64 fields. 28 */ 28 */ 29 struct watch_notification { 29 struct watch_notification { 30 __u32 type:24; 30 __u32 type:24; /* enum watch_notification_type */ 31 __u32 subtype:8; 31 __u32 subtype:8; /* Type-specific subtype (filterable) */ 32 __u32 info; 32 __u32 info; 33 #define WATCH_INFO_LENGTH 0x0000007f 33 #define WATCH_INFO_LENGTH 0x0000007f /* Length of record */ 34 #define WATCH_INFO_LENGTH__SHIFT 0 34 #define WATCH_INFO_LENGTH__SHIFT 0 35 #define WATCH_INFO_ID 0x0000ff00 35 #define WATCH_INFO_ID 0x0000ff00 /* ID of watchpoint */ 36 #define WATCH_INFO_ID__SHIFT 8 36 #define WATCH_INFO_ID__SHIFT 8 37 #define WATCH_INFO_TYPE_INFO 0xffff0000 37 #define WATCH_INFO_TYPE_INFO 0xffff0000 /* Type-specific info */ 38 #define WATCH_INFO_TYPE_INFO__SHIFT 16 38 #define WATCH_INFO_TYPE_INFO__SHIFT 16 39 #define WATCH_INFO_FLAG_0 0x00010000 39 #define WATCH_INFO_FLAG_0 0x00010000 /* Type-specific info, flag bit 0 */ 40 #define WATCH_INFO_FLAG_1 0x00020000 40 #define WATCH_INFO_FLAG_1 0x00020000 /* ... */ 41 #define WATCH_INFO_FLAG_2 0x00040000 41 #define WATCH_INFO_FLAG_2 0x00040000 42 #define WATCH_INFO_FLAG_3 0x00080000 42 #define WATCH_INFO_FLAG_3 0x00080000 43 #define WATCH_INFO_FLAG_4 0x00100000 43 #define WATCH_INFO_FLAG_4 0x00100000 44 #define WATCH_INFO_FLAG_5 0x00200000 44 #define WATCH_INFO_FLAG_5 0x00200000 45 #define WATCH_INFO_FLAG_6 0x00400000 45 #define WATCH_INFO_FLAG_6 0x00400000 46 #define WATCH_INFO_FLAG_7 0x00800000 46 #define WATCH_INFO_FLAG_7 0x00800000 47 }; 47 }; 48 48 49 /* 49 /* 50 * Notification filtering rules (IOC_WATCH_QUE 50 * Notification filtering rules (IOC_WATCH_QUEUE_SET_FILTER). 51 */ 51 */ 52 struct watch_notification_type_filter { 52 struct watch_notification_type_filter { 53 __u32 type; /* Typ 53 __u32 type; /* Type to apply filter to */ 54 __u32 info_filter; /* Fil 54 __u32 info_filter; /* Filter on watch_notification::info */ 55 __u32 info_mask; /* Mas 55 __u32 info_mask; /* Mask of relevant bits in info_filter */ 56 __u32 subtype_filter[8]; /* Bit 56 __u32 subtype_filter[8]; /* Bitmask of subtypes to filter on */ 57 }; 57 }; 58 58 59 struct watch_notification_filter { 59 struct watch_notification_filter { 60 __u32 nr_filters; /* Num 60 __u32 nr_filters; /* Number of filters */ 61 __u32 __reserved; /* Mus 61 __u32 __reserved; /* Must be 0 */ 62 struct watch_notification_type_filter 62 struct watch_notification_type_filter filters[]; 63 }; 63 }; 64 64 65 65 66 /* 66 /* 67 * Extended watch removal notification. This 67 * Extended watch removal notification. This is used optionally if the type 68 * wants to indicate an identifier for the obj 68 * wants to indicate an identifier for the object being watched, if there is 69 * such. This can be distinguished by the len 69 * such. This can be distinguished by the length. 70 * 70 * 71 * type -> WATCH_TYPE_META 71 * type -> WATCH_TYPE_META 72 * subtype -> WATCH_META_REMOVAL_NOTIFICATION 72 * subtype -> WATCH_META_REMOVAL_NOTIFICATION 73 */ 73 */ 74 struct watch_notification_removal { 74 struct watch_notification_removal { 75 struct watch_notification watch; 75 struct watch_notification watch; 76 __u64 id; /* Type-depend 76 __u64 id; /* Type-dependent identifier */ 77 }; 77 }; 78 78 79 /* 79 /* 80 * Type of key/keyring change notification. 80 * Type of key/keyring change notification. 81 */ 81 */ 82 enum key_notification_subtype { 82 enum key_notification_subtype { 83 NOTIFY_KEY_INSTANTIATED = 0, /* Key wa 83 NOTIFY_KEY_INSTANTIATED = 0, /* Key was instantiated (aux is error code) */ 84 NOTIFY_KEY_UPDATED = 1, /* Key wa 84 NOTIFY_KEY_UPDATED = 1, /* Key was updated */ 85 NOTIFY_KEY_LINKED = 2, /* Key (a 85 NOTIFY_KEY_LINKED = 2, /* Key (aux) was added to watched keyring */ 86 NOTIFY_KEY_UNLINKED = 3, /* Key (a 86 NOTIFY_KEY_UNLINKED = 3, /* Key (aux) was removed from watched keyring */ 87 NOTIFY_KEY_CLEARED = 4, /* Keyrin 87 NOTIFY_KEY_CLEARED = 4, /* Keyring was cleared */ 88 NOTIFY_KEY_REVOKED = 5, /* Key wa 88 NOTIFY_KEY_REVOKED = 5, /* Key was revoked */ 89 NOTIFY_KEY_INVALIDATED = 6, /* Key wa 89 NOTIFY_KEY_INVALIDATED = 6, /* Key was invalidated */ 90 NOTIFY_KEY_SETATTR = 7, /* Key's 90 NOTIFY_KEY_SETATTR = 7, /* Key's attributes got changed */ 91 }; 91 }; 92 92 93 /* 93 /* 94 * Key/keyring notification record. 94 * Key/keyring notification record. 95 * - watch.type = WATCH_TYPE_KEY_NOTIFY 95 * - watch.type = WATCH_TYPE_KEY_NOTIFY 96 * - watch.subtype = enum key_notification_typ 96 * - watch.subtype = enum key_notification_type 97 */ 97 */ 98 struct key_notification { 98 struct key_notification { 99 struct watch_notification watch; 99 struct watch_notification watch; 100 __u32 key_id; /* The key/key 100 __u32 key_id; /* The key/keyring affected */ 101 __u32 aux; /* Per-type au 101 __u32 aux; /* Per-type auxiliary data */ 102 }; 102 }; 103 103 104 #endif /* _UAPI_LINUX_WATCH_QUEUE_H */ 104 #endif /* _UAPI_LINUX_WATCH_QUEUE_H */ 105 105
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.