Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_WATCH_QUEUE_H
0003 #define _UAPI_LINUX_WATCH_QUEUE_H
0004 
0005 #include <linux/types.h>
0006 #include <linux/fcntl.h>
0007 #include <linux/ioctl.h>
0008 
0009 #define O_NOTIFICATION_PIPE O_EXCL  /* Parameter to pipe2() selecting notification pipe */
0010 
0011 #define IOC_WATCH_QUEUE_SET_SIZE    _IO('W', 0x60)  /* Set the size in pages */
0012 #define IOC_WATCH_QUEUE_SET_FILTER  _IO('W', 0x61)  /* Set the filter */
0013 
0014 enum watch_notification_type {
0015     WATCH_TYPE_META     = 0,    /* Special record */
0016     WATCH_TYPE_KEY_NOTIFY   = 1,    /* Key change event notification */
0017     WATCH_TYPE__NR      = 2
0018 };
0019 
0020 enum watch_meta_notification_subtype {
0021     WATCH_META_REMOVAL_NOTIFICATION = 0,    /* Watched object was removed */
0022     WATCH_META_LOSS_NOTIFICATION    = 1,    /* Data loss occurred */
0023 };
0024 
0025 /*
0026  * Notification record header.  This is aligned to 64-bits so that subclasses
0027  * can contain __u64 fields.
0028  */
0029 struct watch_notification {
0030     __u32           type:24;    /* enum watch_notification_type */
0031     __u32           subtype:8;  /* Type-specific subtype (filterable) */
0032     __u32           info;
0033 #define WATCH_INFO_LENGTH   0x0000007f  /* Length of record */
0034 #define WATCH_INFO_LENGTH__SHIFT 0
0035 #define WATCH_INFO_ID       0x0000ff00  /* ID of watchpoint */
0036 #define WATCH_INFO_ID__SHIFT    8
0037 #define WATCH_INFO_TYPE_INFO    0xffff0000  /* Type-specific info */
0038 #define WATCH_INFO_TYPE_INFO__SHIFT 16
0039 #define WATCH_INFO_FLAG_0   0x00010000  /* Type-specific info, flag bit 0 */
0040 #define WATCH_INFO_FLAG_1   0x00020000  /* ... */
0041 #define WATCH_INFO_FLAG_2   0x00040000
0042 #define WATCH_INFO_FLAG_3   0x00080000
0043 #define WATCH_INFO_FLAG_4   0x00100000
0044 #define WATCH_INFO_FLAG_5   0x00200000
0045 #define WATCH_INFO_FLAG_6   0x00400000
0046 #define WATCH_INFO_FLAG_7   0x00800000
0047 };
0048 
0049 /*
0050  * Notification filtering rules (IOC_WATCH_QUEUE_SET_FILTER).
0051  */
0052 struct watch_notification_type_filter {
0053     __u32   type;           /* Type to apply filter to */
0054     __u32   info_filter;        /* Filter on watch_notification::info */
0055     __u32   info_mask;      /* Mask of relevant bits in info_filter */
0056     __u32   subtype_filter[8];  /* Bitmask of subtypes to filter on */
0057 };
0058 
0059 struct watch_notification_filter {
0060     __u32   nr_filters;     /* Number of filters */
0061     __u32   __reserved;     /* Must be 0 */
0062     struct watch_notification_type_filter filters[];
0063 };
0064 
0065 
0066 /*
0067  * Extended watch removal notification.  This is used optionally if the type
0068  * wants to indicate an identifier for the object being watched, if there is
0069  * such.  This can be distinguished by the length.
0070  *
0071  * type -> WATCH_TYPE_META
0072  * subtype -> WATCH_META_REMOVAL_NOTIFICATION
0073  */
0074 struct watch_notification_removal {
0075     struct watch_notification watch;
0076     __u64   id;     /* Type-dependent identifier */
0077 };
0078 
0079 /*
0080  * Type of key/keyring change notification.
0081  */
0082 enum key_notification_subtype {
0083     NOTIFY_KEY_INSTANTIATED = 0, /* Key was instantiated (aux is error code) */
0084     NOTIFY_KEY_UPDATED  = 1, /* Key was updated */
0085     NOTIFY_KEY_LINKED   = 2, /* Key (aux) was added to watched keyring */
0086     NOTIFY_KEY_UNLINKED = 3, /* Key (aux) was removed from watched keyring */
0087     NOTIFY_KEY_CLEARED  = 4, /* Keyring was cleared */
0088     NOTIFY_KEY_REVOKED  = 5, /* Key was revoked */
0089     NOTIFY_KEY_INVALIDATED  = 6, /* Key was invalidated */
0090     NOTIFY_KEY_SETATTR  = 7, /* Key's attributes got changed */
0091 };
0092 
0093 /*
0094  * Key/keyring notification record.
0095  * - watch.type = WATCH_TYPE_KEY_NOTIFY
0096  * - watch.subtype = enum key_notification_type
0097  */
0098 struct key_notification {
0099     struct watch_notification watch;
0100     __u32   key_id;     /* The key/keyring affected */
0101     __u32   aux;        /* Per-type auxiliary data */
0102 };
0103 
0104 #endif /* _UAPI_LINUX_WATCH_QUEUE_H */