10858caa4SDavid Howells /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 20858caa4SDavid Howells #ifndef _UAPI_LINUX_WATCH_QUEUE_H 30858caa4SDavid Howells #define _UAPI_LINUX_WATCH_QUEUE_H 40858caa4SDavid Howells 50858caa4SDavid Howells #include <linux/types.h> 6b580b936SDavid Howells #include <linux/fcntl.h> 7c73be61cSDavid Howells #include <linux/ioctl.h> 8b580b936SDavid Howells 9b580b936SDavid Howells #define O_NOTIFICATION_PIPE O_EXCL /* Parameter to pipe2() selecting notification pipe */ 100858caa4SDavid Howells 11c73be61cSDavid Howells #define IOC_WATCH_QUEUE_SET_SIZE _IO('W', 0x60) /* Set the size in pages */ 12c73be61cSDavid Howells #define IOC_WATCH_QUEUE_SET_FILTER _IO('W', 0x61) /* Set the filter */ 13c73be61cSDavid Howells 140858caa4SDavid Howells enum watch_notification_type { 150858caa4SDavid Howells WATCH_TYPE_META = 0, /* Special record */ 16*f7e47677SDavid Howells WATCH_TYPE_KEY_NOTIFY = 1, /* Key change event notification */ 17*f7e47677SDavid Howells WATCH_TYPE__NR = 2 180858caa4SDavid Howells }; 190858caa4SDavid Howells 200858caa4SDavid Howells enum watch_meta_notification_subtype { 210858caa4SDavid Howells WATCH_META_REMOVAL_NOTIFICATION = 0, /* Watched object was removed */ 220858caa4SDavid Howells WATCH_META_LOSS_NOTIFICATION = 1, /* Data loss occurred */ 230858caa4SDavid Howells }; 240858caa4SDavid Howells 250858caa4SDavid Howells /* 260858caa4SDavid Howells * Notification record header. This is aligned to 64-bits so that subclasses 270858caa4SDavid Howells * can contain __u64 fields. 280858caa4SDavid Howells */ 290858caa4SDavid Howells struct watch_notification { 300858caa4SDavid Howells __u32 type:24; /* enum watch_notification_type */ 310858caa4SDavid Howells __u32 subtype:8; /* Type-specific subtype (filterable) */ 320858caa4SDavid Howells __u32 info; 330858caa4SDavid Howells #define WATCH_INFO_LENGTH 0x0000007f /* Length of record */ 340858caa4SDavid Howells #define WATCH_INFO_LENGTH__SHIFT 0 350858caa4SDavid Howells #define WATCH_INFO_ID 0x0000ff00 /* ID of watchpoint */ 360858caa4SDavid Howells #define WATCH_INFO_ID__SHIFT 8 370858caa4SDavid Howells #define WATCH_INFO_TYPE_INFO 0xffff0000 /* Type-specific info */ 380858caa4SDavid Howells #define WATCH_INFO_TYPE_INFO__SHIFT 16 390858caa4SDavid Howells #define WATCH_INFO_FLAG_0 0x00010000 /* Type-specific info, flag bit 0 */ 400858caa4SDavid Howells #define WATCH_INFO_FLAG_1 0x00020000 /* ... */ 410858caa4SDavid Howells #define WATCH_INFO_FLAG_2 0x00040000 420858caa4SDavid Howells #define WATCH_INFO_FLAG_3 0x00080000 430858caa4SDavid Howells #define WATCH_INFO_FLAG_4 0x00100000 440858caa4SDavid Howells #define WATCH_INFO_FLAG_5 0x00200000 450858caa4SDavid Howells #define WATCH_INFO_FLAG_6 0x00400000 460858caa4SDavid Howells #define WATCH_INFO_FLAG_7 0x00800000 470858caa4SDavid Howells }; 480858caa4SDavid Howells 49c73be61cSDavid Howells /* 50c73be61cSDavid Howells * Notification filtering rules (IOC_WATCH_QUEUE_SET_FILTER). 51c73be61cSDavid Howells */ 52c73be61cSDavid Howells struct watch_notification_type_filter { 53c73be61cSDavid Howells __u32 type; /* Type to apply filter to */ 54c73be61cSDavid Howells __u32 info_filter; /* Filter on watch_notification::info */ 55c73be61cSDavid Howells __u32 info_mask; /* Mask of relevant bits in info_filter */ 56c73be61cSDavid Howells __u32 subtype_filter[8]; /* Bitmask of subtypes to filter on */ 57c73be61cSDavid Howells }; 58c73be61cSDavid Howells 59c73be61cSDavid Howells struct watch_notification_filter { 60c73be61cSDavid Howells __u32 nr_filters; /* Number of filters */ 61c73be61cSDavid Howells __u32 __reserved; /* Must be 0 */ 62c73be61cSDavid Howells struct watch_notification_type_filter filters[]; 63c73be61cSDavid Howells }; 64c73be61cSDavid Howells 650858caa4SDavid Howells 660858caa4SDavid Howells /* 670858caa4SDavid Howells * Extended watch removal notification. This is used optionally if the type 680858caa4SDavid Howells * wants to indicate an identifier for the object being watched, if there is 690858caa4SDavid Howells * such. This can be distinguished by the length. 700858caa4SDavid Howells * 710858caa4SDavid Howells * type -> WATCH_TYPE_META 720858caa4SDavid Howells * subtype -> WATCH_META_REMOVAL_NOTIFICATION 730858caa4SDavid Howells */ 740858caa4SDavid Howells struct watch_notification_removal { 750858caa4SDavid Howells struct watch_notification watch; 760858caa4SDavid Howells __u64 id; /* Type-dependent identifier */ 770858caa4SDavid Howells }; 780858caa4SDavid Howells 79*f7e47677SDavid Howells /* 80*f7e47677SDavid Howells * Type of key/keyring change notification. 81*f7e47677SDavid Howells */ 82*f7e47677SDavid Howells enum key_notification_subtype { 83*f7e47677SDavid Howells NOTIFY_KEY_INSTANTIATED = 0, /* Key was instantiated (aux is error code) */ 84*f7e47677SDavid Howells NOTIFY_KEY_UPDATED = 1, /* Key was updated */ 85*f7e47677SDavid Howells NOTIFY_KEY_LINKED = 2, /* Key (aux) was added to watched keyring */ 86*f7e47677SDavid Howells NOTIFY_KEY_UNLINKED = 3, /* Key (aux) was removed from watched keyring */ 87*f7e47677SDavid Howells NOTIFY_KEY_CLEARED = 4, /* Keyring was cleared */ 88*f7e47677SDavid Howells NOTIFY_KEY_REVOKED = 5, /* Key was revoked */ 89*f7e47677SDavid Howells NOTIFY_KEY_INVALIDATED = 6, /* Key was invalidated */ 90*f7e47677SDavid Howells NOTIFY_KEY_SETATTR = 7, /* Key's attributes got changed */ 91*f7e47677SDavid Howells }; 92*f7e47677SDavid Howells 93*f7e47677SDavid Howells /* 94*f7e47677SDavid Howells * Key/keyring notification record. 95*f7e47677SDavid Howells * - watch.type = WATCH_TYPE_KEY_NOTIFY 96*f7e47677SDavid Howells * - watch.subtype = enum key_notification_type 97*f7e47677SDavid Howells */ 98*f7e47677SDavid Howells struct key_notification { 99*f7e47677SDavid Howells struct watch_notification watch; 100*f7e47677SDavid Howells __u32 key_id; /* The key/keyring affected */ 101*f7e47677SDavid Howells __u32 aux; /* Per-type auxiliary data */ 102*f7e47677SDavid Howells }; 103*f7e47677SDavid Howells 1040858caa4SDavid Howells #endif /* _UAPI_LINUX_WATCH_QUEUE_H */ 105