watch_queue.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #include <linux/types.h>
  5. #include <linux/fcntl.h>
  6. #include <linux/ioctl.h>
  7. #define O_NOTIFICATION_PIPE O_EXCL /* Parameter to pipe2() selecting notification pipe */
  8. #define IOC_WATCH_QUEUE_SET_SIZE _IO('W', 0x60) /* Set the size in pages */
  9. #define IOC_WATCH_QUEUE_SET_FILTER _IO('W', 0x61) /* Set the filter */
  10. enum watch_notification_type {
  11. WATCH_TYPE_META = 0, /* Special record */
  12. WATCH_TYPE_KEY_NOTIFY = 1, /* Key change event notification */
  13. WATCH_TYPE__NR = 2
  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. * Notification record header. This is aligned to 64-bits so that subclasses
  21. * can contain __u64 fields.
  22. */
  23. struct watch_notification {
  24. __u32 type:24; /* enum watch_notification_type */
  25. __u32 subtype:8; /* Type-specific subtype (filterable) */
  26. __u32 info;
  27. #define WATCH_INFO_LENGTH 0x0000007f /* Length of record */
  28. #define WATCH_INFO_LENGTH__SHIFT 0
  29. #define WATCH_INFO_ID 0x0000ff00 /* ID of watchpoint */
  30. #define WATCH_INFO_ID__SHIFT 8
  31. #define WATCH_INFO_TYPE_INFO 0xffff0000 /* Type-specific info */
  32. #define WATCH_INFO_TYPE_INFO__SHIFT 16
  33. #define WATCH_INFO_FLAG_0 0x00010000 /* Type-specific info, flag bit 0 */
  34. #define WATCH_INFO_FLAG_1 0x00020000 /* ... */
  35. #define WATCH_INFO_FLAG_2 0x00040000
  36. #define WATCH_INFO_FLAG_3 0x00080000
  37. #define WATCH_INFO_FLAG_4 0x00100000
  38. #define WATCH_INFO_FLAG_5 0x00200000
  39. #define WATCH_INFO_FLAG_6 0x00400000
  40. #define WATCH_INFO_FLAG_7 0x00800000
  41. };
  42. /*
  43. * Notification filtering rules (IOC_WATCH_QUEUE_SET_FILTER).
  44. */
  45. struct watch_notification_type_filter {
  46. __u32 type; /* Type to apply filter to */
  47. __u32 info_filter; /* Filter on watch_notification::info */
  48. __u32 info_mask; /* Mask of relevant bits in info_filter */
  49. __u32 subtype_filter[8]; /* Bitmask of subtypes to filter on */
  50. };
  51. struct watch_notification_filter {
  52. __u32 nr_filters; /* Number of filters */
  53. __u32 __reserved; /* Must be 0 */
  54. struct watch_notification_type_filter filters[];
  55. };
  56. /*
  57. * Extended watch removal notification. This is used optionally if the type
  58. * wants to indicate an identifier for the object being watched, if there is
  59. * such. This can be distinguished by the length.
  60. *
  61. * type -> WATCH_TYPE_META
  62. * subtype -> WATCH_META_REMOVAL_NOTIFICATION
  63. */
  64. struct watch_notification_removal {
  65. struct watch_notification watch;
  66. __u64 id; /* Type-dependent identifier */
  67. };
  68. /*
  69. * Type of key/keyring change notification.
  70. */
  71. enum key_notification_subtype {
  72. NOTIFY_KEY_INSTANTIATED = 0, /* Key was instantiated (aux is error code) */
  73. NOTIFY_KEY_UPDATED = 1, /* Key was updated */
  74. NOTIFY_KEY_LINKED = 2, /* Key (aux) was added to watched keyring */
  75. NOTIFY_KEY_UNLINKED = 3, /* Key (aux) was removed from watched keyring */
  76. NOTIFY_KEY_CLEARED = 4, /* Keyring was cleared */
  77. NOTIFY_KEY_REVOKED = 5, /* Key was revoked */
  78. NOTIFY_KEY_INVALIDATED = 6, /* Key was invalidated */
  79. NOTIFY_KEY_SETATTR = 7, /* Key's attributes got changed */
  80. };
  81. /*
  82. * Key/keyring notification record.
  83. * - watch.type = WATCH_TYPE_KEY_NOTIFY
  84. * - watch.subtype = enum key_notification_type
  85. */
  86. struct key_notification {
  87. struct watch_notification watch;
  88. __u32 key_id; /* The key/keyring affected */
  89. __u32 aux; /* Per-type auxiliary data */
  90. };
  91. #endif /* _UAPI_LINUX_WATCH_QUEUE_H */