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

# VFS\_SET.9

`VFS_SET` — 设置可加载文件系统

## 名称

`VFS_SET`, `vfsconf`

## 概要

```c
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/mount.h>

void
VFS_SET(struct vfsops *vfsops, fsname, int flags)
```

## 描述

`VFS_SET` 为具有给定 `vfsops`、`fsname` 和 `flags` 的可加载模块创建一个 `vfsconf` 结构，并通过使用 `vfs_modevent` 作为事件处理程序调用 [DECLARE\_MODULE(9)](/man/man9/declare_module.9.md) 来声明它。

`flags` 参数的可能取值为：

**`VFCF_STATIC`** 文件系统应在内核中静态可用。

**`VFCF_NETWORK`** 可通过网络导出的文件系统。

**`VFCF_READONLY`** 不支持写操作。

**`VFCF_SYNTHETIC`** 伪文件系统，数据不代表磁盘上的文件。

**`VFCF_LOOPBACK`** 回环文件系统层。

**`VFCF_UNICODE`** 文件名以 Unicode 存储。

**`VFCF_JAIL`** 如果设置了 `allow.mount` 和 `allow.mount.<fsname>` jail 参数，则可以从 jail 内部挂载。

**`VFCF_DELEGADMIN`** 如果 `vfs.usermount` sysctl 设置为 `1`，则支持委托管理。

**`VFCF_SBDRY`** 在 VFS 方法中时，线程挂起在到达停止操作时推迟到用户边界。

## 伪代码

```c
/*
 * 填入我们有特殊方法的字段。
 * 其余字段初始为 null。这告诉 vfs 在文件系统注册期间
 * 将它们更改为指向 vfs_std* 函数的指针。
 */
static struct vfsops myfs_vfsops = {
        .vfs_mount =    myfs_mount,
        .vfs_root =     myfs_root,
        .vfs_statfs =   myfs_statfs,
        .vfs_unmount =  myfs_unmount,
};
VFS_SET(myfs_vfsops, myfs, 0);
```

## 参见

[jail(2)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man2/jail.2.md), [jail(8)](/man/man8/jail.8.md), [DECLARE\_MODULE(9)](/man/man9/declare_module.9.md), vfs\_modevent(9), [vfsconf(9)](/man/man9/vfsconf.9.md)

## 作者

本手册页由 Chad David <davidc@acns.ab.ca> 编写。


---

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