Skip to content

Commit 0858caa

Browse files
committed
uapi: General notification queue definitions
Add UAPI definitions for the general notification queue, including the following pieces: (*) struct watch_notification. This is the metadata header for notification messages. It includes a type and subtype that indicate the source of the message (eg. WATCH_TYPE_MOUNT_NOTIFY) and the kind of the message (eg. NOTIFY_MOUNT_NEW_MOUNT). The header also contains an information field that conveys the following information: - WATCH_INFO_LENGTH. The size of the entry (entries are variable length). - WATCH_INFO_ID. The watch ID specified when the watchpoint was set. - WATCH_INFO_TYPE_INFO. (Sub)type-specific information. - WATCH_INFO_FLAG_*. Flag bits overlain on the type-specific information. For use by the type. All the information in the header can be used in filtering messages at the point of writing into the buffer. (*) struct watch_notification_removal This is an extended watch-removal notification record that includes an 'id' field that can indicate the identifier of the object being removed if available (for instance, a keyring serial number). Signed-off-by: David Howells <[email protected]>
1 parent b9bbe6e commit 0858caa

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

include/uapi/linux/watch_queue.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
7+
enum watch_notification_type {
8+
WATCH_TYPE_META = 0, /* Special record */
9+
WATCH_TYPE__NR = 1
10+
};
11+
12+
enum watch_meta_notification_subtype {
13+
WATCH_META_REMOVAL_NOTIFICATION = 0, /* Watched object was removed */
14+
WATCH_META_LOSS_NOTIFICATION = 1, /* Data loss occurred */
15+
};
16+
17+
/*
18+
* Notification record header. This is aligned to 64-bits so that subclasses
19+
* can contain __u64 fields.
20+
*/
21+
struct watch_notification {
22+
__u32 type:24; /* enum watch_notification_type */
23+
__u32 subtype:8; /* Type-specific subtype (filterable) */
24+
__u32 info;
25+
#define WATCH_INFO_LENGTH 0x0000007f /* Length of record */
26+
#define WATCH_INFO_LENGTH__SHIFT 0
27+
#define WATCH_INFO_ID 0x0000ff00 /* ID of watchpoint */
28+
#define WATCH_INFO_ID__SHIFT 8
29+
#define WATCH_INFO_TYPE_INFO 0xffff0000 /* Type-specific info */
30+
#define WATCH_INFO_TYPE_INFO__SHIFT 16
31+
#define WATCH_INFO_FLAG_0 0x00010000 /* Type-specific info, flag bit 0 */
32+
#define WATCH_INFO_FLAG_1 0x00020000 /* ... */
33+
#define WATCH_INFO_FLAG_2 0x00040000
34+
#define WATCH_INFO_FLAG_3 0x00080000
35+
#define WATCH_INFO_FLAG_4 0x00100000
36+
#define WATCH_INFO_FLAG_5 0x00200000
37+
#define WATCH_INFO_FLAG_6 0x00400000
38+
#define WATCH_INFO_FLAG_7 0x00800000
39+
};
40+
41+
42+
/*
43+
* Extended watch removal notification. This is used optionally if the type
44+
* wants to indicate an identifier for the object being watched, if there is
45+
* such. This can be distinguished by the length.
46+
*
47+
* type -> WATCH_TYPE_META
48+
* subtype -> WATCH_META_REMOVAL_NOTIFICATION
49+
*/
50+
struct watch_notification_removal {
51+
struct watch_notification watch;
52+
__u64 id; /* Type-dependent identifier */
53+
};
54+
55+
#endif /* _UAPI_LINUX_WATCH_QUEUE_H */

0 commit comments

Comments
 (0)