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

# VOP\_CREATE.9

`VOP_CREATE` — 创建文件、套接字、fifo、设备、目录或符号链接

## 名称

`VOP_CREATE`, `VOP_MKNOD`, `VOP_MKDIR`, `VOP_SYMLINK`

## 概要

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

int
VOP_CREATE(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap)

int
VOP_MKNOD(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap)

int
VOP_MKDIR(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap)

int
VOP_SYMLINK(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap, const char *target)
```

## 描述

这些入口点在给定目录中创建新的文件、套接字、fifo、设备、目录或符号链接。

参数为：

**`dvp`** 目录的已锁定 vnode。

**`vpp`** 用于存储生成的已锁定 vnode 的变量地址。

**`cnp`** 创建的路径名组件。

**`vap`** 新对象应具有的创建属性。

**`target`** 符号链接目标的路径名。

当创建对象时，这些入口点在 [VOP\_LOOKUP(9)](/man/man9/vop_lookup.9.md) 之后被调用。

## 锁定

目录 `dvp` 在入口时将被锁定，并且在返回时必须保持锁定。如果调用成功，新对象将以锁定状态返回。

## 返回值

如果成功，新对象的 vnode 将被放入 `*vpp` 并返回零。否则，返回适当的错误。

## 错误

**\[`ENOSPC`]** 文件系统已满。

**\[`EDQUOT`]** 将超过用户的文件系统空间或 inode 配额。

## 参见

[vnode(9)](/man/man9/vnode.9.md), [VOP\_LOOKUP(9)](/man/man9/vop_lookup.9.md)

## 历史

`VOP_SYMLINK` 函数出现于 4.3BSD。

## 作者

本手册页由 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_create.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.
