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

# VOP\_ADVLOCK.9

`VOP_ADVLOCK` — 建议性记录锁定

## 名称

`VOP_ADVLOCK`

## 概要

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

int
VOP_ADVLOCK(struct vnode *vp, caddr_t id, int op, struct flock *fl,
    int flags)
```

## 描述

参数为：

**`F_WAIT`** 等待直到获得锁。

**`F_FLOCK`** 对锁使用 [flock(2)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man2/flock.2.md) 语义。

**`F_POSIX`** 对锁使用 POSIX 语义。

**`F_REMOTE`** 锁所有者是远程 NFS 客户端。

**`F_NOINTR`** 等待锁时屏蔽信号。

**`vp`** 正在被操作的 vnode。

**`id`** 正在更改锁的 id 令牌。

**`op`** 要执行的操作（参见 [fcntl(2)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man2/fcntl.2.md)）。

**`fl`** 锁的描述。

**`flags`** 以下一个或多个：

此入口点操作文件上的建议性记录锁。大多数文件系统将此调用的工作委托给 `lf_advlock`。

## 返回值

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

## 参见

[fcntl(2)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man2/fcntl.2.md), [flock(2)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man2/flock.2.md), [vnode(9)](/man/man9/vnode.9.md)

## 作者

本手册页由 Doug Rabson 编写。


---

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