> 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/4.3-bsd-unix-cao-zuo-xi-tong-she-ji-yu-shi-xian/di-yi-bu-fen-gai-lan/2.8.-she-bei.md).

# 2.8 设备

硬件设备可以分为有结构的和无结构的两类，分别称为块设备（block device）和字符设备（character device）。进程通常通过文件系统中的特殊文件访问设备。对这些文件的 I/O 操作由驻留在内核中的软件模块处理，称为设备驱动（device driver）。多数网络通信硬件设备只能通过进程间通信设施访问，在文件系统名字空间中没有特殊文件。这是因为裸套接字接口提供了比特殊文件更自然的接口。

有结构设备或块设备的典型是磁盘和磁带，包括大多数随机访问设备。内核对面向块的有结构设备支持“读-改-写”式缓冲操作，使它们可以像普通文件那样完全按随机字节寻址的方式读写。文件系统创建在块设备上。

无结构设备指不支持块结构的设备。常见的有通信线路、光栅绘图仪以及不带缓冲的磁带机和磁盘机。无结构设备通常支持大数据块的 I/O 传输。

无结构设备之所以称为字符设备（character device），是因为最早实现的一批是终端设备驱动。内核面向这些设备驱动的接口，后来证明对其他非块结构的设备同样方便。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://book.bsdcn.org/4.3-bsd-unix-cao-zuo-xi-tong-she-ji-yu-shi-xian/di-yi-bu-fen-gai-lan/2.8.-she-bei.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
