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

# VOP\_INOTIFY.9

`VOP_INOTIFY` — vnode inotify 接口

## 名称

`VOP_INOTIFY`

## 概要

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

```c
int
VOP_INOTIFY(struct vnode *vp, struct vnode *dvp,
    struct componentname *cnp, int event, uint32_t cookie)

int
VOP_INOTIFY_ADD_WATCH(struct vnode *vp, struct inotify_softc *sc,
    uint32_t mask, uint32_t *wdp, struct thread *td)
```

## 描述

`VOP_INOTIFY` 操作用于通知 inotify(2) 子系统在 vnode 上发生的文件系统事件。`dvp` 和 `cnp` 参数是可选的，仅用于获取事件的文件名。如果省略这些参数，inotify 子系统将使用文件名缓存来查找 vnode 的名称，但这开销更大。

`VOP_INOTIFY_ADD_WATCH` 操作供 inotify 子系统内部使用，用于向 vnode 添加监视。

## 锁定

`VOP_INOTIFY` 操作不假定任何特定的 vnode 锁定状态。`VOP_INOTIFY_ADD_WATCH` 操作应在 vnode 已锁定时调用。

## 返回值

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

## 参见

[inotify(2)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man2/inotify.2.md), [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_inotify.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.
