-/* $OpenBSD: vfs_init.c,v 1.39 2017/12/11 05:27:40 deraadt Exp $ */
+/* $OpenBSD: vfs_init.c,v 1.40 2018/09/16 11:41:44 visa Exp $ */
/* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */
/*
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/vnode.h>
for (i = 0; i < vfsconflistlen; i++)
vfs_register(&vfsconflist[i]);
}
+
+struct vfsconf *
+vfs_byname(const char *name)
+{
+ struct vfsconf *vfsp;
+
+ for (vfsp = vfsconf; vfsp != NULL; vfsp = vfsp->vfc_next) {
+ if (strcmp(vfsp->vfc_name, name) == 0)
+ break;
+ }
+ return vfsp;
+}
+
+struct vfsconf *
+vfs_bytypenum(int typenum)
+{
+ struct vfsconf *vfsp;
+
+ for (vfsp = vfsconf; vfsp != NULL; vfsp = vfsp->vfc_next) {
+ if (vfsp->vfc_typenum == typenum)
+ break;
+ }
+ return vfsp;
+}
-/* $OpenBSD: vfs_subr.c,v 1.277 2018/07/13 09:25:23 beck Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.278 2018/09/16 11:41:44 visa Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
struct vfsconf *vfsp;
struct mount *mp;
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (!strcmp(vfsp->vfc_name, fstypename))
- break;
+ vfsp = vfs_byname(fstypename);
if (vfsp == NULL)
return (ENODEV);
mp = malloc(sizeof(*mp), M_MOUNT, M_WAITOK|M_ZERO);
return (ENOTDIR); /* overloaded */
if (name[0] != VFS_GENERIC) {
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (vfsp->vfc_typenum == name[0])
- break;
-
+ vfsp = vfs_bytypenum(name[0]);
if (vfsp == NULL || vfsp->vfc_vfsops->vfs_sysctl == NULL)
return (EOPNOTSUPP);
if (namelen < 3)
return (ENOTDIR); /* overloaded */
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (vfsp->vfc_typenum == name[2])
- break;
-
+ vfsp = vfs_bytypenum(name[2]);
if (vfsp == NULL)
return (EOPNOTSUPP);
-/* $OpenBSD: vfs_syscalls.c,v 1.305 2018/09/01 17:02:12 deraadt Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.306 2018/09/16 11:41:44 visa Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
vput(vp);
goto fail;
}
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) {
- if (!strcmp(vfsp->vfc_name, fstypename))
- break;
- }
-
+ vfsp = vfs_byname(fstypename);
if (vfsp == NULL) {
vput(vp);
error = EOPNOTSUPP;
-/* $OpenBSD: mount.h,v 1.138 2018/06/19 13:01:34 helg Exp $ */
+/* $OpenBSD: mount.h,v 1.139 2018/09/16 11:41:44 visa Exp $ */
/* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */
/*
void vfsinit(void);
int vfs_register(struct vfsconf *);
int vfs_unregister(struct vfsconf *);
+struct vfsconf *vfs_byname(const char *);
+struct vfsconf *vfs_bytypenum(int);
#else /* _KERNEL */
__BEGIN_DECLS
int fstatfs(int, struct statfs *);