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

# VOP\_BMAP.9

`VOP_BMAP` — 逻辑块号到物理块号的转换

## 名称

`VOP_BMAP`

## 概要

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

int
VOP_BMAP(struct vnode *vp, daddr_t bn, struct bufobj **bop,
    daddr_t *bnp, int *runp, int *runb)
```

## 描述

此 vnode 调用用于查找文件系统底层设备上存储文件的给定逻辑块的物理块号。其参数为：

**`vp`** 文件的 vnode。

**`bn`** 由 `vp` 标识的文件内的逻辑块号。

**`bop`** 与文件系统底层设备关联的缓冲区对象的返回存储位置。

**`bnp`** 物理块号的返回存储位置。

**`runp`** 可以与请求块同时高效读取的后续逻辑块数量的返回存储位置。这通常是物理块连续分配的逻辑块数量。但是文件系统可以自由地按自己认为合适的方式定义"高效"。

**`runb`** 类似于 `runp`，但针对的是前导块而非后续块。

任何返回参数都可以为 `NULL`，以指示调用者不关心该信息。

## 锁定

vnode 在入口时将被锁定，并在返回时应保持锁定状态。

## 返回值

成功时返回零，否则返回错误代码。

## 参见

[vnode(9)](/man/man9/vnode.9.md)

## 历史

`bmap` 函数首次出现于 4.2BSD。

## 作者

本手册页由 Alan Somers 编写。


---

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