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

# VOP\_ADVISE(9)

`VOP_ADVISE` — 应用关于文件数据使用的建议

## 名称

`VOP_ADVISE`

## 概要

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

int
VOP_ADVISE(struct vnode *vp, off_t start, off_t end, int advice)
```

## 描述

此调用对文件数据的一个范围应用建议。它用于实现 [posix\_fadvise(2)](/man/sys/posix_fadvise.2.md) 系统调用。

其参数为：

**`POSIX_FADV_WILLNEED`** 如果文件数据尚未驻留，则发起异步读取。

**`POSIX_FADV_DONTNEED`** 降低干净文件数据的内存优先级或丢弃干净文件数据。

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

**`start`** 文件数据范围的起始位置。

**`end`** 文件数据范围的结束位置。值为 `OFF_MAX` 表示建议将应用直到文件末尾。

**`advice`** 要应用于文件数据的操作类型。可能取值为：

如果 `start` 和 `end` 偏移量都为零，则操作应应用于整个文件。请注意，此调用仅为建议性质，并且可以在请求范围的子集上执行请求的操作（包括完全不执行），仍然返回成功。

## 锁定

文件在入口时应处于未锁定状态。

## 返回值

如果调用成功则返回零，否则返回适当的错误代码。

## 错误

**\[`EINVAL`]** 为 `advice` 给出了无效值。

## 参见

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


---

# 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_advise.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.
