€•ÍŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ(/translations/zh_CN/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/zh_TW/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/it_IT/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ja_JP/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ko_KR/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/pt_BR/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/sp_SP/core-api/watch_queue”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒGeneral notification mechanism”h]”hŒGeneral notification mechanism”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒB/var/lib/git/docbuild/linux/Documentation/core-api/watch_queue.rst”h´KubhŒ paragraph”“”)�”}”(hŒÛThe general notification mechanism is built on top of the standard pipe driver whereby it effectively splices notification messages from the kernel into pipes opened by userspace. This can be used in conjunction with::”h]”hŒÚThe general notification mechanism is built on top of the standard pipe driver whereby it effectively splices notification messages from the kernel into pipes opened by userspace. This can be used in conjunction with:”…”�”}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhŒ literal_block”“”)�”}”(hŒ* Key/keyring notifications”h]”hŒ* Key/keyring notifications”…”�”}”hhÝsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hÛh³hÊh´K hh·h²hubhÌ)�”}”(hŒ,The notifications buffers can be enabled by:”h]”hŒ,The notifications buffers can be enabled by:”…”�”}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hh·h²hubhŒ block_quote”“”)�”}”(hŒB"General setup"/"General notification queue" (CONFIG_WATCH_QUEUE) ”h]”hÌ)�”}”(hŒA"General setup"/"General notification queue" (CONFIG_WATCH_QUEUE)”h]”hŒI“General setupâ€�/â€�General notification queueâ€� (CONFIG_WATCH_QUEUE)”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khhýubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´Khh·h²hubhÌ)�”}”(hŒ)This document has the following sections:”h]”hŒ)This document has the following sections:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhŒtopic”“”)�”}”(hhh]”hŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hhh]”hÌ)�”}”(hhh]”hŒ reference”“”)�”}”(hhh]”hŒOverview”…”�”}”(hj7h²hh³Nh´Nubah}”(h]”Œid1”ah ]”h"]”h$]”h&]”Œrefid”Œoverview”uh1j5hj2ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj/ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒMessage Structure”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”Œid2”ah ]”h"]”h$]”h&]”Œrefid”Œmessage-structure”uh1j5hjVubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjSubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒ$Watch List (Notification Source) API”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”Œid3”ah ]”h"]”h$]”h&]”Œrefid”Œ"watch-list-notification-source-api”uh1j5hjxubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjuubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒ%Watch Queue (Notification Output) API”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”Œid4”ah ]”h"]”h$]”h&]”Œrefid”Œ#watch-queue-notification-output-api”uh1j5hjšubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj—ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒWatch Subscription API”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”Œid5”ah ]”h"]”h$]”h&]”Œrefid”Œwatch-subscription-api”uh1j5hj¼ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj¹ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒNotification Posting API”…”�”}”(hjáh²hh³Nh´Nubah}”(h]”Œid6”ah ]”h"]”h$]”h&]”Œrefid”Œnotification-posting-api”uh1j5hjÞubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjÛubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒ Watch Sources”…”�”}”(hjh²hh³Nh´Nubah}”(h]”Œid7”ah ]”h"]”h$]”h&]”Œrefid”Œ watch-sources”uh1j5hjubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjýubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒEvent Filtering”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”Œid8”ah ]”h"]”h$]”h&]”Œrefid”Œevent-filtering”uh1j5hj"ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubj.)�”}”(hhh]”hÌ)�”}”(hhh]”j6)�”}”(hhh]”hŒUserspace Code Example”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”Œid9”ah ]”h"]”h$]”h&]”Œrefid”Œuserspace-code-example”uh1j5hjDubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjAubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj*ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j(hj%h²hh³Nh´Nubah}”(h]”Œcontents”ah ]”(Œcontents”Œlocal”eh"]”Œcontents”ah$]”h&]”uh1j#h³hÊh´Khh·h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒOverview”h]”hŒOverview”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefid”j@uh1hºhjsh²hh³hÊh´KubhÌ)�”}”(hXŠThis facility appears as a pipe that is opened in a special mode. The pipe's internal ring buffer is used to hold messages that are generated by the kernel. These messages are then read out by read(). Splice and similar are disabled on such pipes due to them wanting to, under some circumstances, revert their additions to the ring - which might end up interleaved with notification messages.”h]”hXŒThis facility appears as a pipe that is opened in a special mode. The pipe’s internal ring buffer is used to hold messages that are generated by the kernel. These messages are then read out by read(). Splice and similar are disabled on such pipes due to them wanting to, under some circumstances, revert their additions to the ring - which might end up interleaved with notification messages.”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjsh²hubhÌ)�”}”(hXThe owner of the pipe has to tell the kernel which sources it would like to watch through that pipe. Only sources that have been connected to a pipe will insert messages into it. Note that a source may be bound to multiple pipes and insert messages into all of them simultaneously.”h]”hXThe owner of the pipe has to tell the kernel which sources it would like to watch through that pipe. Only sources that have been connected to a pipe will insert messages into it. Note that a source may be bound to multiple pipes and insert messages into all of them simultaneously.”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hjsh²hubhÌ)�”}”(hŒ|Filters may also be emplaced on a pipe so that certain source types and subevents can be ignored if they're not of interest.”h]”hŒ~Filters may also be emplaced on a pipe so that certain source types and subevents can be ignored if they’re not of interest.”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K%hjsh²hubhÌ)�”}”(hX"A message will be discarded if there isn't a slot available in the ring or if no preallocated message buffer is available. In both of these cases, read() will insert a WATCH_META_LOSS_NOTIFICATION message into the output buffer after the last message currently in the buffer has been read.”h]”hX$A message will be discarded if there isn’t a slot available in the ring or if no preallocated message buffer is available. In both of these cases, read() will insert a WATCH_META_LOSS_NOTIFICATION message into the output buffer after the last message currently in the buffer has been read.”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K(hjsh²hubhÌ)�”}”(hX#Note that when producing a notification, the kernel does not wait for the consumers to collect it, but rather just continues on. This means that notifications can be generated whilst spinlocks are held and also protects the kernel from being held up indefinitely by a userspace malfunction.”h]”hX#Note that when producing a notification, the kernel does not wait for the consumers to collect it, but rather just continues on. This means that notifications can be generated whilst spinlocks are held and also protects the kernel from being held up indefinitely by a userspace malfunction.”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K-hjsh²hubeh}”(h]”jFah ]”h"]”Œoverview”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒMessage Structure”h]”hŒMessage Structure”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„jbuh1hºhjÒh²hh³hÊh´K4ubhÌ)�”}”(hŒ1Notification messages begin with a short header::”h]”hŒ0Notification messages begin with a short header:”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K6hjÒh²hubhÜ)�”}”(hŒhstruct watch_notification { __u32 type:24; __u32 subtype:8; __u32 info; };”h]”hŒhstruct watch_notification { __u32 type:24; __u32 subtype:8; __u32 info; };”…”�”}”hjñsbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´K8hjÒh²hubhÌ)�”}”(hX*"type" indicates the source of the notification record and "subtype" indicates the type of record from that source (see the Watch Sources section below). The type may also be "WATCH_TYPE_META". This is a special record type generated internally by the watch queue itself. There are two subtypes:”h]”hX6“typeâ€� indicates the source of the notification record and “subtypeâ€� indicates the type of record from that source (see the Watch Sources section below). The type may also be “WATCH_TYPE_METAâ€�. This is a special record type generated internally by the watch queue itself. There are two subtypes:”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K>hjÒh²hubhü)�”}”(hŒA* WATCH_META_REMOVAL_NOTIFICATION * WATCH_META_LOSS_NOTIFICATION ”h]”j))�”}”(hhh]”(j.)�”}”(hŒWATCH_META_REMOVAL_NOTIFICATION”h]”hÌ)�”}”(hjh]”hŒWATCH_META_REMOVAL_NOTIFICATION”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KChjubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hjubj.)�”}”(hŒWATCH_META_LOSS_NOTIFICATION ”h]”hÌ)�”}”(hŒWATCH_META_LOSS_NOTIFICATION”h]”hŒWATCH_META_LOSS_NOTIFICATION”…”�”}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KDhj+ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hjubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1j(h³hÊh´KChj ubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´KChjÒh²hubhÌ)�”}”(hŒ–The first indicates that an object on which a watch was installed was removed or destroyed and the second indicates that some messages have been lost.”h]”hŒ–The first indicates that an object on which a watch was installed was removed or destroyed and the second indicates that some messages have been lost.”…”�”}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KFhjÒh²hubhÌ)�”}”(hŒ."info" indicates a bunch of things, including:”h]”hŒ2“infoâ€� indicates a bunch of things, including:”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KIhjÒh²hubhü)�”}”(hXa* The length of the message in bytes, including the header (mask with WATCH_INFO_LENGTH and shift by WATCH_INFO_LENGTH__SHIFT). This indicates the size of the record, which may be between 8 and 127 bytes. * The watch ID (mask with WATCH_INFO_ID and shift by WATCH_INFO_ID__SHIFT). This indicates that caller's ID of the watch, which may be between 0 and 255. Multiple watches may share a queue, and this provides a means to distinguish them. * A type-specific field (WATCH_INFO_TYPE_INFO). This is set by the notification producer to indicate some meaning specific to the type and subtype. ”h]”j))�”}”(hhh]”(j.)�”}”(hŒÌThe length of the message in bytes, including the header (mask with WATCH_INFO_LENGTH and shift by WATCH_INFO_LENGTH__SHIFT). This indicates the size of the record, which may be between 8 and 127 bytes. ”h]”hÌ)�”}”(hŒËThe length of the message in bytes, including the header (mask with WATCH_INFO_LENGTH and shift by WATCH_INFO_LENGTH__SHIFT). This indicates the size of the record, which may be between 8 and 127 bytes.”h]”hŒËThe length of the message in bytes, including the header (mask with WATCH_INFO_LENGTH and shift by WATCH_INFO_LENGTH__SHIFT). This indicates the size of the record, which may be between 8 and 127 bytes.”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KKhjtubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hjqubj.)�”}”(hŒìThe watch ID (mask with WATCH_INFO_ID and shift by WATCH_INFO_ID__SHIFT). This indicates that caller's ID of the watch, which may be between 0 and 255. Multiple watches may share a queue, and this provides a means to distinguish them. ”h]”hÌ)�”}”(hŒëThe watch ID (mask with WATCH_INFO_ID and shift by WATCH_INFO_ID__SHIFT). This indicates that caller's ID of the watch, which may be between 0 and 255. Multiple watches may share a queue, and this provides a means to distinguish them.”h]”hŒíThe watch ID (mask with WATCH_INFO_ID and shift by WATCH_INFO_ID__SHIFT). This indicates that caller’s ID of the watch, which may be between 0 and 255. Multiple watches may share a queue, and this provides a means to distinguish them.”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KOhjŒubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hjqubj.)�”}”(hŒ“A type-specific field (WATCH_INFO_TYPE_INFO). This is set by the notification producer to indicate some meaning specific to the type and subtype. ”h]”hÌ)�”}”(hŒ’A type-specific field (WATCH_INFO_TYPE_INFO). This is set by the notification producer to indicate some meaning specific to the type and subtype.”h]”hŒ’A type-specific field (WATCH_INFO_TYPE_INFO). This is set by the notification producer to indicate some meaning specific to the type and subtype.”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KThj¤ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hjqubeh}”(h]”h ]”h"]”h$]”h&]”jIjJuh1j(h³hÊh´KKhjmubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´KKhjÒh²hubhÌ)�”}”(hŒCEverything in info apart from the length can be used for filtering.”h]”hŒCEverything in info apart from the length can be used for filtering.”…”�”}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KXhjÒh²hubhÌ)�”}”(hŒ…The header can be followed by supplementary information. The format of this is at the discretion is defined by the type and subtype.”h]”hŒ…The header can be followed by supplementary information. The format of this is at the discretion is defined by the type and subtype.”…”�”}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KZhjÒh²hubeh}”(h]”jhah ]”h"]”Œmessage structure”ah$]”h&]”uh1hµhh·h²hh³hÊh´K4ubh¶)�”}”(hhh]”(h»)�”}”(hŒ$Watch List (Notification Source) API”h]”hŒ$Watch List (Notification Source) API”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„j„uh1hºhjëh²hh³hÊh´K_ubhÌ)�”}”(hX–A "watch list" is a list of watchers that are subscribed to a source of notifications. A list may be attached to an object (say a key or a superblock) or may be global (say for device events). From a userspace perspective, a non-global watch list is typically referred to by reference to the object it belongs to (such as using KEYCTL_NOTIFY and giving it a key serial number to watch that specific key).”h]”hXšA “watch listâ€� is a list of watchers that are subscribed to a source of notifications. A list may be attached to an object (say a key or a superblock) or may be global (say for device events). From a userspace perspective, a non-global watch list is typically referred to by reference to the object it belongs to (such as using KEYCTL_NOTIFY and giving it a key serial number to watch that specific key).”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kahjëh²hubhÌ)�”}”(hŒ=To manage a watch list, the following functions are provided:”h]”hŒ=To manage a watch list, the following functions are provided:”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khhjëh²hubhü)�”}”(hX$* :: void init_watch_list(struct watch_list *wlist, void (*release_watch)(struct watch *wlist)); Initialise a watch list. If ``release_watch`` is not NULL, then this indicates a function that should be called when the watch_list object is destroyed to discard any references the watch list holds on the watched object. * ``void remove_watch_list(struct watch_list *wlist);`` This removes all of the watches subscribed to a watch_list and frees them and then destroys the watch_list object itself. ”h]”j))�”}”(hhh]”(j.)�”}”(hX]:: void init_watch_list(struct watch_list *wlist, void (*release_watch)(struct watch *wlist)); Initialise a watch list. If ``release_watch`` is not NULL, then this indicates a function that should be called when the watch_list object is destroyed to discard any references the watch list holds on the watched object. ”h]”(hÜ)�”}”(hŒpvoid init_watch_list(struct watch_list *wlist, void (*release_watch)(struct watch *wlist));”h]”hŒpvoid init_watch_list(struct watch_list *wlist, void (*release_watch)(struct watch *wlist));”…”�”}”hj#sbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´KlhjubhÌ)�”}”(hŒÞInitialise a watch list. If ``release_watch`` is not NULL, then this indicates a function that should be called when the watch_list object is destroyed to discard any references the watch list holds on the watched object.”h]”(hŒInitialise a watch list. If ”…”�”}”(hj1h²hh³Nh´NubhŒliteral”“”)�”}”(hŒ``release_watch``”h]”hŒ release_watch”…”�”}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj1ubhŒ° is not NULL, then this indicates a function that should be called when the watch_list object is destroyed to discard any references the watch list holds on the watched object.”…”�”}”(hj1h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kohjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjubj.)�”}”(hŒ²``void remove_watch_list(struct watch_list *wlist);`` This removes all of the watches subscribed to a watch_list and frees them and then destroys the watch_list object itself. ”h]”(hÌ)�”}”(hŒ5``void remove_watch_list(struct watch_list *wlist);``”h]”j:)�”}”(hj_h]”hŒ1void remove_watch_list(struct watch_list *wlist);”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj]ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KthjYubhÌ)�”}”(hŒyThis removes all of the watches subscribed to a watch_list and frees them and then destroys the watch_list object itself.”h]”hŒyThis removes all of the watches subscribed to a watch_list and frees them and then destroys the watch_list object itself.”…”�”}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KvhjYubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjubeh}”(h]”h ]”h"]”h$]”h&]”jIjJuh1j(h³hÊh´Kjhjubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´Kjhjëh²hubeh}”(h]”jŠah ]”h"]”Œ$watch list (notification source) api”ah$]”h&]”uh1hµhh·h²hh³hÊh´K_ubh¶)�”}”(hhh]”(h»)�”}”(hŒ%Watch Queue (Notification Output) API”h]”hŒ%Watch Queue (Notification Output) API”…”�”}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„j¦uh1hºhj›h²hh³hÊh´K{ubhÌ)�”}”(hXA "watch queue" is the buffer allocated by an application that notification records will be written into. The workings of this are hidden entirely inside of the pipe device driver, but it is necessary to gain a reference to it to set a watch. These can be managed with:”h]”hXA “watch queueâ€� is the buffer allocated by an application that notification records will be written into. The workings of this are hidden entirely inside of the pipe device driver, but it is necessary to gain a reference to it to set a watch. These can be managed with:”…”�”}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K}hj›h²hubhü)�”}”(hX¥* ``struct watch_queue *get_watch_queue(int fd);`` Since watch queues are indicated to the kernel by the fd of the pipe that implements the buffer, userspace must hand that fd through a system call. This can be used to look up an opaque pointer to the watch queue from the system call. * ``void put_watch_queue(struct watch_queue *wqueue);`` This discards the reference obtained from ``get_watch_queue()``. ”h]”j))�”}”(hhh]”(j.)�”}”(hX``struct watch_queue *get_watch_queue(int fd);`` Since watch queues are indicated to the kernel by the fd of the pipe that implements the buffer, userspace must hand that fd through a system call. This can be used to look up an opaque pointer to the watch queue from the system call. ”h]”(hÌ)�”}”(hŒ0``struct watch_queue *get_watch_queue(int fd);``”h]”j:)�”}”(hjÇh]”hŒ,struct watch_queue *get_watch_queue(int fd);”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjÅubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‚hjÁubhÌ)�”}”(hŒêSince watch queues are indicated to the kernel by the fd of the pipe that implements the buffer, userspace must hand that fd through a system call. This can be used to look up an opaque pointer to the watch queue from the system call.”h]”hŒêSince watch queues are indicated to the kernel by the fd of the pipe that implements the buffer, userspace must hand that fd through a system call. This can be used to look up an opaque pointer to the watch queue from the system call.”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K„hjÁubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hj¾ubj.)�”}”(hŒy``void put_watch_queue(struct watch_queue *wqueue);`` This discards the reference obtained from ``get_watch_queue()``. ”h]”(hÌ)�”}”(hŒ5``void put_watch_queue(struct watch_queue *wqueue);``”h]”j:)�”}”(hjöh]”hŒ1void put_watch_queue(struct watch_queue *wqueue);”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjôubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‰hjðubhÌ)�”}”(hŒ@This discards the reference obtained from ``get_watch_queue()``.”h]”(hŒ*This discards the reference obtained from ”…”�”}”(hj h²hh³Nh´Nubj:)�”}”(hŒ``get_watch_queue()``”h]”hŒget_watch_queue()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj ubhŒ.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‹hjðubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hj¾ubeh}”(h]”h ]”h"]”h$]”h&]”jIjJuh1j(h³hÊh´K‚hjºubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´K‚hj›h²hubeh}”(h]”j¬ah ]”h"]”Œ%watch queue (notification output) api”ah$]”h&]”uh1hµhh·h²hh³hÊh´K{ubh¶)�”}”(hhh]”(h»)�”}”(hŒWatch Subscription API”h]”hŒWatch Subscription API”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„jÈuh1hºhjDh²hh³hÊh´K�ubhÌ)�”}”(hX(A "watch" is a subscription on a watch list, indicating the watch queue, and thus the buffer, into which notification records should be written. The watch queue object may also carry filtering rules for that object, as set by userspace. Some parts of the watch struct can be set by the driver::”h]”hX+A “watchâ€� is a subscription on a watch list, indicating the watch queue, and thus the buffer, into which notification records should be written. The watch queue object may also carry filtering rules for that object, as set by userspace. Some parts of the watch struct can be set by the driver:”…”�”}”(hjUh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‘hjDh²hubhÜ)�”}”(hXEstruct watch { union { u32 info_id; /* ID to be OR'd in to info field */ ... }; void *private; /* Private data for the watched object */ u64 id; /* Internal identifier */ ... };”h]”hXEstruct watch { union { u32 info_id; /* ID to be OR'd in to info field */ ... }; void *private; /* Private data for the watched object */ u64 id; /* Internal identifier */ ... };”…”�”}”hjcsbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´K–hjDh²hubhÌ)�”}”(hX The ``info_id`` value should be an 8-bit number obtained from userspace and shifted by WATCH_INFO_ID__SHIFT. This is OR'd into the WATCH_INFO_ID field of struct watch_notification::info when and if the notification is written into the associated watch queue buffer.”h]”(hŒThe ”…”�”}”(hjqh²hh³Nh´Nubj:)�”}”(hŒ ``info_id``”h]”hŒinfo_id”…”�”}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjqubhŒý value should be an 8-bit number obtained from userspace and shifted by WATCH_INFO_ID__SHIFT. This is OR’d into the WATCH_INFO_ID field of struct watch_notification::info when and if the notification is written into the associated watch queue buffer.”…”�”}”(hjqh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hjDh²hubhÌ)�”}”(hŒŠThe ``private`` field is the driver's data associated with the watch_list and is cleaned up by the ``watch_list::release_watch()`` method.”h]”(hŒThe ”…”�”}”(hj‘h²hh³Nh´Nubj:)�”}”(hŒ ``private``”h]”hŒprivate”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj‘ubhŒV field is the driver’s data associated with the watch_list and is cleaned up by the ”…”�”}”(hj‘h²hh³Nh´Nubj:)�”}”(hŒ``watch_list::release_watch()``”h]”hŒwatch_list::release_watch()”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj‘ubhŒ method.”…”�”}”(hj‘h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¥hjDh²hubhÌ)�”}”(hŒdThe ``id`` field is the source's ID. Notifications that are posted with a different ID are ignored.”h]”(hŒThe ”…”�”}”(hjÃh²hh³Nh´Nubj:)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjÃubhŒ\ field is the source’s ID. Notifications that are posted with a different ID are ignored.”…”�”}”(hjÃh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¨hjDh²hubhÌ)�”}”(hŒ7The following functions are provided to manage watches:”h]”hŒ7The following functions are provided to manage watches:”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K«hjDh²hubhü)�”}”(hX* ``void init_watch(struct watch *watch, struct watch_queue *wqueue);`` Initialise a watch object, setting its pointer to the watch queue, using appropriate barriering to avoid lockdep complaints. * ``int add_watch_to_object(struct watch *watch, struct watch_list *wlist);`` Subscribe a watch to a watch list (notification source). The driver-settable fields in the watch struct must have been set before this is called. * :: int remove_watch_from_object(struct watch_list *wlist, struct watch_queue *wqueue, u64 id, false); Remove a watch from a watch list, where the watch must match the specified watch queue (``wqueue``) and object identifier (``id``). A notification (``WATCH_META_REMOVAL_NOTIFICATION``) is sent to the watch queue to indicate that the watch got removed. * ``int remove_watch_from_object(struct watch_list *wlist, NULL, 0, true);`` Remove all the watches from a watch list. It is expected that this will be called preparatory to destruction and that the watch list will be inaccessible to new watches by this point. A notification (``WATCH_META_REMOVAL_NOTIFICATION``) is sent to the watch queue of each subscribed watch to indicate that the watch got removed. ”h]”j))�”}”(hhh]”(j.)�”}”(hŒÄ``void init_watch(struct watch *watch, struct watch_queue *wqueue);`` Initialise a watch object, setting its pointer to the watch queue, using appropriate barriering to avoid lockdep complaints. ”h]”(hÌ)�”}”(hŒE``void init_watch(struct watch *watch, struct watch_queue *wqueue);``”h]”j:)�”}”(hjþh]”hŒAvoid init_watch(struct watch *watch, struct watch_queue *wqueue);”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjüubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K­hjøubhÌ)�”}”(hŒ|Initialise a watch object, setting its pointer to the watch queue, using appropriate barriering to avoid lockdep complaints.”h]”hŒ|Initialise a watch object, setting its pointer to the watch queue, using appropriate barriering to avoid lockdep complaints.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¯hjøubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjõubj.)�”}”(hŒà``int add_watch_to_object(struct watch *watch, struct watch_list *wlist);`` Subscribe a watch to a watch list (notification source). The driver-settable fields in the watch struct must have been set before this is called. ”h]”(hÌ)�”}”(hŒK``int add_watch_to_object(struct watch *watch, struct watch_list *wlist);``”h]”j:)�”}”(hj-h]”hŒGint add_watch_to_object(struct watch *watch, struct watch_list *wlist);”…”�”}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj+ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K²hj'ubhÌ)�”}”(hŒ’Subscribe a watch to a watch list (notification source). The driver-settable fields in the watch struct must have been set before this is called.”h]”hŒ’Subscribe a watch to a watch list (notification source). The driver-settable fields in the watch struct must have been set before this is called.”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K´hj'ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjõubj.)�”}”(hX«:: int remove_watch_from_object(struct watch_list *wlist, struct watch_queue *wqueue, u64 id, false); Remove a watch from a watch list, where the watch must match the specified watch queue (``wqueue``) and object identifier (``id``). A notification (``WATCH_META_REMOVAL_NOTIFICATION``) is sent to the watch queue to indicate that the watch got removed. ”h]”(hÜ)�”}”(hŒœint remove_watch_from_object(struct watch_list *wlist, struct watch_queue *wqueue, u64 id, false);”h]”hŒœint remove_watch_from_object(struct watch_list *wlist, struct watch_queue *wqueue, u64 id, false);”…”�”}”hjZsbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´KºhjVubhÌ)�”}”(hŒüRemove a watch from a watch list, where the watch must match the specified watch queue (``wqueue``) and object identifier (``id``). A notification (``WATCH_META_REMOVAL_NOTIFICATION``) is sent to the watch queue to indicate that the watch got removed.”h]”(hŒXRemove a watch from a watch list, where the watch must match the specified watch queue (”…”�”}”(hjhh²hh³Nh´Nubj:)�”}”(hŒ ``wqueue``”h]”hŒwqueue”…”�”}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjhubhŒ) and object identifier (”…”�”}”(hjhh²hh³Nh´Nubj:)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjhubhŒ). A notification (”…”�”}”(hjhh²hh³Nh´Nubj:)�”}”(hŒ#``WATCH_META_REMOVAL_NOTIFICATION``”h]”hŒWATCH_META_REMOVAL_NOTIFICATION”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjhubhŒD) is sent to the watch queue to indicate that the watch got removed.”…”�”}”(hjhh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¾hjVubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjõubj.)�”}”(hX˜``int remove_watch_from_object(struct watch_list *wlist, NULL, 0, true);`` Remove all the watches from a watch list. It is expected that this will be called preparatory to destruction and that the watch list will be inaccessible to new watches by this point. A notification (``WATCH_META_REMOVAL_NOTIFICATION``) is sent to the watch queue of each subscribed watch to indicate that the watch got removed. ”h]”(hÌ)�”}”(hŒJ``int remove_watch_from_object(struct watch_list *wlist, NULL, 0, true);``”h]”j:)�”}”(hj¸h]”hŒFint remove_watch_from_object(struct watch_list *wlist, NULL, 0, true);”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj¶ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÃhj²ubhÌ)�”}”(hXJRemove all the watches from a watch list. It is expected that this will be called preparatory to destruction and that the watch list will be inaccessible to new watches by this point. A notification (``WATCH_META_REMOVAL_NOTIFICATION``) is sent to the watch queue of each subscribed watch to indicate that the watch got removed.”h]”(hŒÊRemove all the watches from a watch list. It is expected that this will be called preparatory to destruction and that the watch list will be inaccessible to new watches by this point. A notification (”…”�”}”(hjÍh²hh³Nh´Nubj:)�”}”(hŒ#``WATCH_META_REMOVAL_NOTIFICATION``”h]”hŒWATCH_META_REMOVAL_NOTIFICATION”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjÍubhŒ]) is sent to the watch queue of each subscribed watch to indicate that the watch got removed.”…”�”}”(hjÍh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÅhj²ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjõubeh}”(h]”h ]”h"]”h$]”h&]”jIjJuh1j(h³hÊh´K­hjñubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´K­hjDh²hubeh}”(h]”jÎah ]”h"]”Œwatch subscription api”ah$]”h&]”uh1hµhh·h²hh³hÊh´K�ubh¶)�”}”(hhh]”(h»)�”}”(hŒNotification Posting API”h]”hŒNotification Posting API”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„jêuh1hºhjh²hh³hÊh´KÍubhÌ)�”}”(hŒwTo post a notification to watch list so that the subscribed watches can see it, the following function should be used::”h]”hŒvTo post a notification to watch list so that the subscribed watches can see it, the following function should be used:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÏhjh²hubhÜ)�”}”(hŒÍvoid post_watch_notification(struct watch_list *wlist, struct watch_notification *n, const struct cred *cred, u64 id);”h]”hŒÍvoid post_watch_notification(struct watch_list *wlist, struct watch_notification *n, const struct cred *cred, u64 id);”…”�”}”hj%sbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´KÒhjh²hubhÌ)�”}”(hŒÝThe notification should be preformatted and a pointer to the header (``n``) should be passed in. The notification may be larger than this and the size in units of buffer slots is noted in ``n->info & WATCH_INFO_LENGTH``.”h]”(hŒEThe notification should be preformatted and a pointer to the header (”…”�”}”(hj3h²hh³Nh´Nubj:)�”}”(hŒ``n``”h]”hŒn”…”�”}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj3ubhŒs) should be passed in. The notification may be larger than this and the size in units of buffer slots is noted in ”…”�”}”(hj3h²hh³Nh´Nubj:)�”}”(hŒ``n->info & WATCH_INFO_LENGTH``”h]”hŒn->info & WATCH_INFO_LENGTH”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj3ubhŒ.”…”�”}”(hj3h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K×hjh²hubhÌ)�”}”(hŒîThe ``cred`` struct indicates the credentials of the source (subject) and is passed to the LSMs, such as SELinux, to allow or suppress the recording of the note in each individual queue according to the credentials of that queue (object).”h]”(hŒThe ”…”�”}”(hjeh²hh³Nh´Nubj:)�”}”(hŒ``cred``”h]”hŒcred”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hjeubhŒâ struct indicates the credentials of the source (subject) and is passed to the LSMs, such as SELinux, to allow or suppress the recording of the note in each individual queue according to the credentials of that queue (object).”…”�”}”(hjeh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÛhjh²hubhÌ)�”}”(hŒšThe ``id`` is the ID of the source object (such as the serial number on a key). Only watches that have the same ID set in them will see this notification.”h]”(hŒThe ”…”�”}”(hj…h²hh³Nh´Nubj:)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj…ubhŒ� is the ID of the source object (such as the serial number on a key). Only watches that have the same ID set in them will see this notification.”…”�”}”(hj…h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kàhjh²hubeh}”(h]”jðah ]”h"]”Œnotification posting api”ah$]”h&]”uh1hµhh·h²hh³hÊh´KÍubh¶)�”}”(hhh]”(h»)�”}”(hŒ Watch Sources”h]”hŒ Watch Sources”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„j uh1hºhj¬h²hh³hÊh´KåubhÌ)�”}”(hŒIAny particular buffer can be fed from multiple sources. Sources include:”h]”hŒIAny particular buffer can be fed from multiple sources. Sources include:”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kçhj¬h²hubhü)�”}”(hŒç* WATCH_TYPE_KEY_NOTIFY Notifications of this type indicate changes to keys and keyrings, including the changes of keyring contents or the attributes of keys. See Documentation/security/keys/core.rst for more information. ”h]”j))�”}”(hhh]”j.)�”}”(hŒßWATCH_TYPE_KEY_NOTIFY Notifications of this type indicate changes to keys and keyrings, including the changes of keyring contents or the attributes of keys. See Documentation/security/keys/core.rst for more information. ”h]”(hÌ)�”}”(hŒWATCH_TYPE_KEY_NOTIFY”h]”hŒWATCH_TYPE_KEY_NOTIFY”…”�”}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KéhjÒubhÌ)�”}”(hŒ†Notifications of this type indicate changes to keys and keyrings, including the changes of keyring contents or the attributes of keys.”h]”hŒ†Notifications of this type indicate changes to keys and keyrings, including the changes of keyring contents or the attributes of keys.”…”�”}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KëhjÒubhÌ)�”}”(hŒ>See Documentation/security/keys/core.rst for more information.”h]”hŒ>See Documentation/security/keys/core.rst for more information.”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KîhjÒubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjÏubah}”(h]”h ]”h"]”h$]”h&]”jIjJuh1j(h³hÊh´KéhjËubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´Kéhj¬h²hubeh}”(h]”jah ]”h"]”Œ watch sources”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kåubh¶)�”}”(hhh]”(h»)�”}”(hŒEvent Filtering”h]”hŒEvent Filtering”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„j.uh1hºhjh²hh³hÊh´KòubhÌ)�”}”(hŒrOnce a watch queue has been created, a set of filters can be applied to limit the events that are received using::”h]”hŒqOnce a watch queue has been created, a set of filters can be applied to limit the events that are received using:”…”�”}”(hj*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kôhjh²hubhÜ)�”}”(hŒistruct watch_notification_filter filter = { ... }; ioctl(fd, IOC_WATCH_QUEUE_SET_FILTER, &filter)”h]”hŒistruct watch_notification_filter filter = { ... }; ioctl(fd, IOC_WATCH_QUEUE_SET_FILTER, &filter)”…”�”}”hj8sbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´K÷hjh²hubhÌ)�”}”(hŒ.The filter description is a variable of type::”h]”hŒ-The filter description is a variable of type:”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kühjh²hubhÜ)�”}”(hŒ–struct watch_notification_filter { __u32 nr_filters; __u32 __reserved; struct watch_notification_type_filter filters[]; };”h]”hŒ–struct watch_notification_filter { __u32 nr_filters; __u32 __reserved; struct watch_notification_type_filter filters[]; };”…”�”}”hjTsbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´Kþhjh²hubhÌ)�”}”(hŒ�Where "nr_filters" is the number of filters in filters[] and "__reserved" should be 0. The "filters" array has elements of the following type::”h]”hŒ›Where “nr_filtersâ€� is the number of filters in filters[] and “__reservedâ€� should be 0. The “filtersâ€� array has elements of the following type:”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjh²hubhÜ)�”}”(hŒ›struct watch_notification_type_filter { __u32 type; __u32 info_filter; __u32 info_mask; __u32 subtype_filter[8]; };”h]”hŒ›struct watch_notification_type_filter { __u32 type; __u32 info_filter; __u32 info_mask; __u32 subtype_filter[8]; };”…”�”}”hjpsbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´Mhjh²hubhÌ)�”}”(hŒWhere:”h]”hŒWhere:”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjh²hubhü)�”}”(hXI* ``type`` is the event type to filter for and should be something like "WATCH_TYPE_KEY_NOTIFY" * ``info_filter`` and ``info_mask`` act as a filter on the info field of the notification record. The notification is only written into the buffer if:: (watch.info & info_mask) == info_filter This could be used, for example, to ignore events that are not exactly on the watched point in a mount tree. * ``subtype_filter`` is a bitmask indicating the subtypes that are of interest. Bit 0 of subtype_filter[0] corresponds to subtype 0, bit 1 to subtype 1, and so on. ”h]”j))�”}”(hhh]”(j.)�”}”(hŒ^``type`` is the event type to filter for and should be something like "WATCH_TYPE_KEY_NOTIFY" ”h]”hÌ)�”}”(hŒ]``type`` is the event type to filter for and should be something like "WATCH_TYPE_KEY_NOTIFY"”h]”(j:)�”}”(hŒ``type``”h]”hŒtype”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj—ubhŒY is the event type to filter for and should be something like “WATCH_TYPE_KEY_NOTIFYâ€�”…”�”}”(hj—h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj“ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj�ubj.)�”}”(hX2``info_filter`` and ``info_mask`` act as a filter on the info field of the notification record. The notification is only written into the buffer if:: (watch.info & info_mask) == info_filter This could be used, for example, to ignore events that are not exactly on the watched point in a mount tree. ”h]”(hÌ)�”}”(hŒ–``info_filter`` and ``info_mask`` act as a filter on the info field of the notification record. The notification is only written into the buffer if::”h]”(j:)�”}”(hŒ``info_filter``”h]”hŒ info_filter”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj½ubhŒ and ”…”�”}”(hj½h²hh³Nh´Nubj:)�”}”(hŒ ``info_mask``”h]”hŒ info_mask”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj½ubhŒt act as a filter on the info field of the notification record. The notification is only written into the buffer if:”…”�”}”(hj½h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¹ubhÜ)�”}”(hŒ'(watch.info & info_mask) == info_filter”h]”hŒ'(watch.info & info_mask) == info_filter”…”�”}”hjësbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´Mhj¹ubhÌ)�”}”(hŒlThis could be used, for example, to ignore events that are not exactly on the watched point in a mount tree.”h]”hŒlThis could be used, for example, to ignore events that are not exactly on the watched point in a mount tree.”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¹ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hj�ubj.)�”}”(hŒ£``subtype_filter`` is a bitmask indicating the subtypes that are of interest. Bit 0 of subtype_filter[0] corresponds to subtype 0, bit 1 to subtype 1, and so on. ”h]”hÌ)�”}”(hŒ¢``subtype_filter`` is a bitmask indicating the subtypes that are of interest. Bit 0 of subtype_filter[0] corresponds to subtype 0, bit 1 to subtype 1, and so on.”h]”(j:)�”}”(hŒ``subtype_filter``”h]”hŒsubtype_filter”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j9hj ubhŒ� is a bitmask indicating the subtypes that are of interest. Bit 0 of subtype_filter[0] corresponds to subtype 0, bit 1 to subtype 1, and so on.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j-hj�ubeh}”(h]”h ]”h"]”h$]”h&]”jIjJuh1j(h³hÊh´MhjŒubah}”(h]”h ]”h"]”h$]”h&]”uh1hûh³hÊh´Mhjh²hubhÌ)�”}”(hŒƒIf the argument to the ioctl() is NULL, then the filters will be removed and all events from the watched sources will come through.”h]”hŒƒIf the argument to the ioctl() is NULL, then the filters will be removed and all events from the watched sources will come through.”…”�”}”(hj? h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjh²hubeh}”(h]”j4ah ]”h"]”Œevent filtering”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kòubh¶)�”}”(hhh]”(h»)�”}”(hŒUserspace Code Example”h]”hŒUserspace Code Example”…”�”}”(hjW h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”j„jPuh1hºhjT h²hh³hÊh´M$ubhÌ)�”}”(hŒ7A buffer is created with something like the following::”h]”hŒ6A buffer is created with something like the following:”…”�”}”(hje h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M&hjT h²hubhÜ)�”}”(hŒDpipe2(fds, O_TMPFILE); ioctl(fds[1], IOC_WATCH_QUEUE_SET_SIZE, 256);”h]”hŒDpipe2(fds, O_TMPFILE); ioctl(fds[1], IOC_WATCH_QUEUE_SET_SIZE, 256);”…”�”}”hjs sbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´M(hjT h²hubhÌ)�”}”(hŒstatic void consumer(int rfd, struct watch_queue_buffer *buf) { unsigned char buffer[128]; ssize_t buf_len; while (buf_len = read(rfd, buffer, sizeof(buffer)), buf_len > 0 ) { void *p = buffer; void *end = buffer + buf_len; while (p < end) { union { struct watch_notification n; unsigned char buf1[128]; } n; size_t largest, len; largest = end - p; if (largest > 128) largest = 128; memcpy(&n, p, largest); len = (n->info & WATCH_INFO_LENGTH) >> WATCH_INFO_LENGTH__SHIFT; if (len == 0 || len > largest) return; switch (n.n.type) { case WATCH_TYPE_META: got_meta(&n.n); case WATCH_TYPE_KEY_NOTIFY: saw_key_change(&n.n); break; } p += len; } } }”h]”hX>static void consumer(int rfd, struct watch_queue_buffer *buf) { unsigned char buffer[128]; ssize_t buf_len; while (buf_len = read(rfd, buffer, sizeof(buffer)), buf_len > 0 ) { void *p = buffer; void *end = buffer + buf_len; while (p < end) { union { struct watch_notification n; unsigned char buf1[128]; } n; size_t largest, len; largest = end - p; if (largest > 128) largest = 128; memcpy(&n, p, largest); len = (n->info & WATCH_INFO_LENGTH) >> WATCH_INFO_LENGTH__SHIFT; if (len == 0 || len > largest) return; switch (n.n.type) { case WATCH_TYPE_META: got_meta(&n.n); case WATCH_TYPE_KEY_NOTIFY: saw_key_change(&n.n); break; } p += len; } } }”…”�”}”hj« sbah}”(h]”h ]”h"]”h$]”h&]”hëhìuh1hÛh³hÊh´M1hjT h²hubeh}”(h]”jVah ]”h"]”Œuserspace code example”ah$]”h&]”uh1hµhh·h²hh³hÊh´M$ubeh}”(h]”Œgeneral-notification-mechanism”ah ]”h"]”Œgeneral notification mechanism”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jë Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jÅ j jpjkjÏjFjèjhj˜jŠjAj¬jjÎj©jðjjjQ j4j½ jVuŒ nametypes”}”(jÅ ‰jp‰jωjè‰j˜‰jA‰j‰j©‰j‰jQ ‰j½ ‰uh}”(j h·jkj%jFjsjhjÒjŠjëj¬j›jÎjDjðjjj¬j4jjVjT j@j7jbjYj„j{j¦j�jÈj¿jêjáj jj.j%jPjGuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”jù K s…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.