> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/devctl_notify.9.md).

# devctl\_notify.9

`devctl_notify` — 通过 devctl 向用户态发送消息

## 名称

`devctl_notify`

## 概要

```c
#include <sys/devctl.h>

void
devctl_notify(const char *system, const char *subsystem,
    const char *type, const char *data)
```

## 描述

通过 [devctl(4)](/man/man4/devctl.4.md) 向用户态发送通知。这些消息的格式参见 [devctl(4)](/man/man4/devctl.4.md)。

`devctl_notify` 函数使用以下模板创建字符串：

```sh
snprintf(buffer, sizeof(buffer), "!system=%s subsystem=%s type=%s",
   system, subsystem, type);
```

`system`、`subsystem` 和 `type` 指针不能为 NULL。

`data` 参数可以为 NULL（表示无附加内容）或为 [devctl(4)](/man/man4/devctl.4.md) 正确格式的消息。会在上述模板后添加一个空格，并将此参数原样复制以构成传递给用户态的消息。发送者应在仅传递用户态无法自行发现的数据与传递用户态决定如何处理消息时所需的所有数据之间取得平衡。

当前总消息长度限制略低于 1kb。发送者应尽量保持远低于此限制。

## 参见

[devctl(4)](/man/man4/devctl.4.md), devd(8)

## 作者

本手册页由 M. Warner Losh 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/devctl_notify.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
