44#include <sys/fnv_hash.h>
46#include <sys/kernel.h>
47#include <sys/linker.h>
51#include <sys/syscallsubr.h>
52#include <sys/sysctl.h>
54#include <sys/malloc.h>
82 "Set vfc_typenum using a hash calculation on vfc_name, so that it does not"
83 "change when file systems are loaded in a different order.");
119 if (!strcmp(
name,
"ffs"))
121 TAILQ_FOREACH(vfsp, &
vfsconf, vfc_list) {
122 if (!strcmp(
name, vfsp->vfc_name))
151 loaded = (*error == 0);
152 if (*error == EEXIST)
173 TSRAW(curthread, TS_ENTER,
"VFS_MOUNT", mp->mnt_vfc->vfc_name);
174 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
175 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_mount)(mp);
176 sigallowstop(prev_stops);
177 TSRAW(curthread, TS_EXIT,
"VFS_MOUNT", mp->mnt_vfc->vfc_name);
186 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
187 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_unmount)(mp, mntflags);
188 sigallowstop(prev_stops);
197 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
198 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_root)(mp,
flags, vpp);
199 sigallowstop(prev_stops);
208 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
209 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_cachedroot)(mp,
flags, vpp);
210 sigallowstop(prev_stops);
220 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
221 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_quotactl)(mp, cmd, uid, arg,
223 sigallowstop(prev_stops);
232 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
233 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_statfs)(mp, sbp);
234 sigallowstop(prev_stops);
243 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
244 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_sync)(mp, waitfor);
245 sigallowstop(prev_stops);
254 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
255 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_vget)(mp, ino,
flags, vpp);
256 sigallowstop(prev_stops);
266 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
267 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_fhtovp)(mp, fidp,
flags, vpp);
268 sigallowstop(prev_stops);
274 struct ucred **credp,
int *numsecflavors,
int *secflavors)
278 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
279 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_checkexp)(mp, nam, exflg, credp,
280 numsecflavors, secflavors);
281 sigallowstop(prev_stops);
291 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
292 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_extattrctl)(mp, cmd,
294 sigallowstop(prev_stops);
303 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
304 rc = (*mp->mnt_vfc->vfc_vfsops_sd->vfs_sysctl)(mp, op, req);
305 sigallowstop(prev_stops);
314 if (*mp->mnt_vfc->vfc_vfsops_sd->vfs_susp_clean == NULL)
316 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
317 (*mp->mnt_vfc->vfc_vfsops_sd->vfs_susp_clean)(mp);
318 sigallowstop(prev_stops);
326 if (*mp->mnt_vfc->vfc_vfsops_sd->vfs_reclaim_lowervp == NULL)
328 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
329 (*mp->mnt_vfc->vfc_vfsops_sd->vfs_reclaim_lowervp)(mp, vp);
330 sigallowstop(prev_stops);
338 if (*mp->mnt_vfc->vfc_vfsops_sd->vfs_unlink_lowervp == NULL)
340 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
341 (*(mp)->mnt_vfc->vfc_vfsops_sd->vfs_unlink_lowervp)(mp, vp);
342 sigallowstop(prev_stops);
350 prev_stops = sigdeferstop(SIGDEFERSTOP_SILENT);
351 (*mp->mnt_vfc->vfc_vfsops_sd->vfs_purge)(mp);
352 sigallowstop(prev_stops);
379 struct sysctl_oid *oidp;
380 struct vfsops *vfsops;
391 if (vfc->vfc_version != VFS_VERSION) {
392 printf(
"ERROR: filesystem %s, unsupported ABI version %x\n",
393 vfc->vfc_name, vfc->vfc_version);
409 hashval = fnv_32_str(vfc->vfc_name, FNV1_32_INIT);
414 TAILQ_FOREACH(tvfc, &
vfsconf, vfc_list) {
415 if (hashval == tvfc->vfc_typenum) {
416 if (hashval == 255 && secondpass == 0) {
424 }
while (tvfc != NULL);
425 vfc->vfc_typenum = hashval;
430 TAILQ_INSERT_TAIL(&
vfsconf, vfc, vfc_list);
438 KASSERT(vfc->vfc_vfsops != NULL,
439 (
"Filesystem %s has no vfsops", vfc->vfc_name));
443 vfsops = vfc->vfc_vfsops;
444 KASSERT(vfsops->vfs_mount != NULL,
445 (
"Filesystem %s has no mount op", vfc->vfc_name));
446 KASSERT(vfsops->vfs_unmount != NULL,
447 (
"Filesystem %s has no unmount op", vfc->vfc_name));
449 if (vfsops->vfs_root == NULL)
452 if (vfsops->vfs_quotactl == NULL)
455 if (vfsops->vfs_statfs == NULL)
458 if (vfsops->vfs_sync == NULL)
466 if (vfsops->vfs_vget == NULL)
469 if (vfsops->vfs_fhtovp == NULL)
472 if (vfsops->vfs_checkexp == NULL)
475 if (vfsops->vfs_init == NULL)
478 if (vfsops->vfs_uninit == NULL)
481 if (vfsops->vfs_extattrctl == NULL)
484 if (vfsops->vfs_sysctl == NULL)
487 if ((vfc->vfc_flags & VFCF_SBDRY) != 0) {
488 vfc->vfc_vfsops_sd = vfc->vfc_vfsops;
492 if (vfc->vfc_flags & VFCF_JAIL)
498 if ((vfc->vfc_flags & VFCF_SBDRY) != 0)
499 vfc->vfc_vfsops_sd->vfs_init(vfc);
501 vfc->vfc_vfsops->vfs_init(vfc);
515 SLIST_FOREACH(oidp, SYSCTL_CHILDREN(&sysctl___vfs), oid_link) {
516 if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) {
518 oidp->oid_number = vfc->vfc_typenum;
533 int error, maxtypenum;
541 if (vfsp->vfc_refcount != 0) {
546 if ((vfc->vfc_flags & VFCF_SBDRY) != 0) {
547 if (vfc->vfc_vfsops_sd->vfs_uninit != NULL)
548 error = vfc->vfc_vfsops_sd->vfs_uninit(vfsp);
550 if (vfc->vfc_vfsops->vfs_uninit != NULL)
551 error = vfc->vfc_vfsops->vfs_uninit(vfsp);
557 TAILQ_REMOVE(&
vfsconf, vfsp, vfc_list);
558 maxtypenum = VFS_GENERIC;
559 TAILQ_FOREACH(vfsp, &
vfsconf, vfc_list)
560 if (maxtypenum < vfsp->vfc_typenum)
561 maxtypenum = vfsp->vfc_typenum;
device_property_type_t type
void prison_add_vfs(struct vfsconf *vfsp)
int kern_kldload(struct thread *td, const char *file, int *fileid)
int kern_kldunload(struct thread *td, int fileid, int flags)
void sysctl_unregister_oid(struct sysctl_oid *oidp)
void sysctl_wunlock(void)
void sysctl_register_oid(struct sysctl_oid *oidp)
int printf(const char *fmt,...)
int vfs_stdsysctl(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
int vfs_stdextattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, int attrnamespace, const char *attrname)
int vfs_stdvget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
int vfs_stdroot(struct mount *mp, int flags, struct vnode **vpp)
int vfs_stdstatfs(struct mount *mp, struct statfs *sbp)
int vfs_stdinit(struct vfsconf *vfsp)
int vfs_stdquotactl(struct mount *mp, int cmds, uid_t uid, void *arg, bool *mp_busy)
int vfs_stdfhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
int vfs_stduninit(struct vfsconf *vfsp)
int vfs_stdnosync(struct mount *mp, int waitfor)
int vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, uint64_t *extflagsp, struct ucred **credanonp, int *numsecflavors, int *secflavors)
static int vfs_extattrctl_sigdefer(struct mount *mp, int cmd, struct vnode *filename_vp, int attrnamespace, const char *attrname)
struct vfsconfhead vfsconf
static int vfs_unregister(struct vfsconf *)
static int vfs_unmount_sigdefer(struct mount *mp, int mntflags)
MALLOC_DEFINE(M_VNODE, "vnodes", "Dynamically allocated vnodes")
static int vfs_register(struct vfsconf *)
static int vfs_sysctl_sigdefer(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
int vfs_modevent(module_t mod, int type, void *data)
static int vfs_checkexp_sigdefer(struct mount *mp, struct sockaddr *nam, uint64_t *exflg, struct ucred **credp, int *numsecflavors, int *secflavors)
static int vfs_sync_sigdefer(struct mount *mp, int waitfor)
static void vfs_purge_sigdefer(struct mount *mp)
SYSCTL_INT(_vfs, OID_AUTO, typenumhash, CTLFLAG_RDTUN, &vfs_typenumhash, 0, "Set vfc_typenum using a hash calculation on vfc_name, so that it does not" "change when file systems are loaded in a different order.")
static void vfs_unlink_lowervp_sigdefer(struct mount *mp, struct vnode *vp)
static void vfs_reclaim_lowervp_sigdefer(struct mount *mp, struct vnode *vp)
static int vfs_typenumhash
struct vfsconf * vfs_byname_kld(const char *fstype, struct thread *td, int *error)
static int vfs_statfs_sigdefer(struct mount *mp, struct statfs *sbp)
static int vfs_fhtovp_sigdefer(struct mount *mp, struct fid *fidp, int flags, struct vnode **vpp)
struct vfsconf * vfs_byname(const char *name)
static int vfs_quotactl_sigdefer(struct mount *mp, int cmd, uid_t uid, void *arg, bool *mp_busy)
static void vfs_susp_clean_sigdefer(struct mount *mp)
static int vfs_mount_sigdefer(struct mount *mp)
static struct vfsconf * vfs_byname_locked(const char *name)
SX_SYSINIT(vfsconf, &vfsconf_sx, "vfsconf")
static int vfs_root_sigdefer(struct mount *mp, int flags, struct vnode **vpp)
static struct vfsops vfsops_sigdefer
static int vfs_cachedroot_sigdefer(struct mount *mp, int flags, struct vnode **vpp)
static int vfs_vget_sigdefer(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
void vattr_null(struct vattr *vap)