> 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/bus_get_property.9.md).

# BUS\_GET\_PROPERTY.9

`BUS_GET_PROPERTY` — 获取子设备的特定属性

## 名称

`BUS_GET_PROPERTY`

## 概要

```c
#include <sys/param.h>
#include <sys/bus.h>
```

```c
ssize_t
BUS_GET_PROPERTY(device_t dev, device_t child, const char *propname,
    void *propvalue, size_t size, device_property_type_t type)
```

## 描述

`BUS_GET_PROPERTY` 方法由需要访问存储在总线上的子设备特定数据的驱动程序代码调用。属性具有名称和关联的值。实现应向 `propvalue` 复制至多 `size` 个字节。

`BUS_GET_PROPERTY` 支持通过 `type` 参数指定的不同属性类型。`size` 保证是底层属性类型的整数倍。如果不支持某种类型，`BUS_GET_PROPERTY` 应返回 -1。

## 注意事项

如果 `propvalue` 为 `NULL` 或 `size` 为零，实现应仅返回属性的大小。

## 返回值

成功时返回属性大小，否则返回 -1。

## 参见

[device(9)](/man/man9/device.9.md), [device\_get\_property(9)](/man/man9/device_get_property.9.md)

## 作者

本手册页由 Bartlomiej Grzesik 编写。


---

# 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/bus_get_property.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.
