]> git.saurik.com Git - apple/xnu.git/blame - bsd/miscfs/routefs/routefs_ops.c
xnu-7195.81.3.tar.gz
[apple/xnu.git] / bsd / miscfs / routefs / routefs_ops.c
CommitLineData
490019cf 1/*
cb323159 2 * Copyright (c) 2019 Apple Inc. All rights reserved.
490019cf
A
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
490019cf
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
0a7de745 14 *
490019cf
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
490019cf
A
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
0a7de745 25 *
490019cf
A
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/vnode_internal.h>
33#include <sys/proc.h>
34#include <sys/kauth.h>
35#include <sys/mount_internal.h>
36#include <sys/fcntl.h>
37#include <sys/unistd.h>
38#include <sys/malloc.h>
39#include <vfs/vfs_support.h>
40
41#include <libkern/OSAtomic.h>
42
43#if CONFIG_MACF
44#include <security/mac_framework.h>
45#endif
46
47#include "routefs.h"
48
49static int routefs_init(__unused struct vfsconf *vfsp);
50static int routefs_mount(struct mount *mp, __unused vnode_t devvp, __unused user_addr_t data, vfs_context_t ctx);
51static int routefs_start(__unused struct mount *mp, __unused int flags, __unused vfs_context_t ctx);
52static int routefs_unmount( struct mount *mp, int mntflags, __unused vfs_context_t ctx);
53static int routefs_root(struct mount *mp, struct vnode **vpp, __unused vfs_context_t ctx);
54static int routefs_statfs( struct mount *mp, struct vfsstatfs *sbp, __unused vfs_context_t ctx);
55static int routefs_vfs_getattr(__unused mount_t mp, struct vfs_attr *fsap, __unused vfs_context_t ctx);
56static int routefs_sync(__unused struct mount *mp, __unused int waitfor, __unused vfs_context_t ctx);
57static int routefs_vget(__unused struct mount *mp, __unused ino64_t ino, __unused struct vnode **vpp, __unused vfs_context_t ctx);
0a7de745
A
58static int routefs_fhtovp(__unused struct mount *mp, __unused int fhlen, __unused unsigned char *fhp, __unused struct vnode **vpp, __unused vfs_context_t ctx);
59static int routefs_vptofh(__unused struct vnode *vp, __unused int *fhlenp, __unused unsigned char *fhp, __unused vfs_context_t ctx);
490019cf 60static int routefs_sysctl(__unused int *name, __unused u_int namelen, __unused user_addr_t oldp,
0a7de745
A
61 __unused size_t *oldlenp, __unused user_addr_t newp,
62 __unused size_t newlen, __unused vfs_context_t ctx);
490019cf
A
63static int routefserr_lookup(__unused struct vnop_lookup_args * args);
64
65static int routefserr_setlabel(__unused struct vnop_setlabel_args * args);
66
67
68lck_grp_t * routefs_lck_grp;
69lck_grp_attr_t * routefs_lck_grp_attr;
70lck_attr_t * routefs_lck_attr;
71lck_mtx_t routefs_mutex;
72
73#define ROUTEFS_LOCK() lck_mtx_lock(&routefs_mutex)
74#define ROUTEFS_UNLOCK() lck_mtx_unlock(&routefs_mutex)
75static int _lock_inited = 0;
76static boolean_t _fs_alreadyMounted = FALSE; /* atleast a mount of this filesystem is present */
77
78static int
79routefs_init(__unused struct vfsconf *vfsp)
80{
0a7de745
A
81 routefs_lck_grp_attr = lck_grp_attr_alloc_init();
82 routefs_lck_grp = lck_grp_alloc_init("routefs_lock", routefs_lck_grp_attr);
83 routefs_lck_attr = lck_attr_alloc_init();
84 lck_mtx_init(&routefs_mutex, routefs_lck_grp, routefs_lck_attr);
85 _lock_inited = 1;
86
87 return 0;
490019cf
A
88}
89
90static int
0a7de745 91routefs_mount(struct mount *mp, __unused vnode_t devvp, user_addr_t data, vfs_context_t ctx)
490019cf 92{
0a7de745
A
93 struct routefs_mount *routefs_mp_p = NULL; /* routefs specific mount info */
94 int error = EINVAL;
95 struct routefs_args * rargs = (struct routefs_args *)data;
96
490019cf
A
97 /*-
98 * If they just want to update, we don't need to do anything.
99 */
0a7de745 100 if (mp->mnt_flag & MNT_UPDATE) {
490019cf
A
101 return 0;
102 }
103
0a7de745
A
104
105 /* check for root mount only */
106 if ((error = proc_suser(current_proc())) != 0) {
107 goto out;
108 }
109
110 if (vfs_iskernelmount(mp) == FALSE) {
111 error = EPERM;
112 goto out;
113 }
114
115 if (_fs_alreadyMounted == TRUE) {
116 /* if a filesystem is mounted, it needs to be unmounted prior to mount again */
117 error = EPERM;
118 goto out;
119 }
120
490019cf
A
121 /* Advisory locking should be handled at the VFS layer */
122 vfs_setlocklocal(mp);
123
124 /*-
125 * Well, it's not an update, it's a real mount request.
126 * Time to get dirty.
127 * HERE we should check to see if we are already mounted here.
128 */
129
130 MALLOC(routefs_mp_p, struct routefs_mount *, sizeof(struct routefs_mount),
0a7de745
A
131 M_TEMP, M_WAITOK);
132 if (routefs_mp_p == NULL) {
133 return ENOMEM;
134 }
490019cf 135 bzero(routefs_mp_p, sizeof(*routefs_mp_p));
0a7de745 136
490019cf
A
137 routefs_mp_p->route_mount = mp;
138
0a7de745
A
139 if (rargs->route_rvp == NULLVP) {
140 error = EACCES;
141 goto out;
142 }
143
144 strlcpy(routefs_mp_p->route_path, rargs->route_path, MAXPATHLEN);
145 routefs_mp_p->route_rvp = rargs->route_rvp;
146 routefs_mp_p->route_vpvid = vnode_vid(rargs->route_rvp);
147
148 if (vnode_ref(routefs_mp_p->route_rvp) != 0) {
149 error = EACCES;
150 goto out;
151 }
152
153 /*
490019cf
A
154 * Fill out some fields
155 */
156 __IGNORE_WCASTALIGN(mp->mnt_data = (qaddr_t)routefs_mp_p);
ea3f0419 157 mp->mnt_vfsstat.f_fsid.val[0] = (int32_t)VM_KERNEL_ADDRHASH(routefs_mp_p);
490019cf
A
158 mp->mnt_vfsstat.f_fsid.val[1] = vfs_typenum(mp);
159 mp->mnt_flag |= MNT_LOCAL;
160
161 /*-
162 * Copy in the name of the directory the filesystem
163 * is to be mounted on.
164 * And we clear the remainder of the character strings
165 * to be tidy.
166 */
0a7de745 167
490019cf 168 bzero(mp->mnt_vfsstat.f_mntfromname, MAXPATHLEN);
0a7de745 169 bcopy("routefs", mp->mnt_vfsstat.f_mntfromname, 5);
490019cf 170 (void)routefs_statfs(mp, &mp->mnt_vfsstat, ctx);
0a7de745 171 _fs_alreadyMounted = TRUE; /* yep, fs is in play now */
490019cf
A
172 error = 0;
173out:
0a7de745
A
174 if (error != 0) {
175 if (routefs_mp_p != NULL) {
176 FREE(routefs_mp_p, M_TEMP);
177 }
178 }
490019cf
A
179 return error;
180}
181
182
183static int
184routefs_start(__unused struct mount *mp, __unused int flags, __unused vfs_context_t ctx)
185{
186 return 0;
187}
188
189/*-
190 * Unmount the filesystem described by mp.
191 */
192static int
193routefs_unmount( struct mount *mp, int mntflags, __unused vfs_context_t ctx)
194{
195 struct routefs_mount *routefs_mp_p = (struct routefs_mount *)mp->mnt_data;
196 int flags = 0;
197 int force = 0;
198 int error;
0a7de745
A
199
200 /* check for root unmount only */
201 if ((error = proc_suser(current_proc())) != 0) {
202 return error;
203 }
490019cf
A
204
205 if (mntflags & MNT_FORCE) {
206 flags |= FORCECLOSE;
207 force = 1;
208 }
0a7de745
A
209 /* giveup the ioref of vnode, no longer need it */
210 if (routefs_mp_p->route_rvp != NULLVP) {
211 if (vnode_getwithref(routefs_mp_p->route_rvp) == 0) {
212 vnode_rele(routefs_mp_p->route_rvp);
213 vnode_put(routefs_mp_p->route_rvp);
214 routefs_mp_p->route_rvp = NULLVP;
215 }
216 }
217 /* no vnodes, ignore any errors */
218 (void)vflush(mp, NULLVP, flags);
219 FREE(routefs_mp_p, M_TEMP);
490019cf
A
220 mp->mnt_data = (qaddr_t)0;
221 mp->mnt_flag &= ~MNT_LOCAL;
0a7de745 222 _fs_alreadyMounted = FALSE; /* unmounted the fs, only one allowed at a time */
490019cf
A
223 return 0;
224}
225
226/* return the address of the root vnode in *vpp */
227static int
228routefs_root(struct mount *mp, struct vnode **vpp, __unused vfs_context_t ctx)
229{
230 struct routefs_mount *routefs_mp_p = (struct routefs_mount *)(mp->mnt_data);
0a7de745
A
231 int error = 0;
232
233 /* check for nullvp incase its being rolled */
234 if (routefs_mp_p->route_rvp == NULLVP) {
235 ROUTEFS_LOCK();
236 if (routefs_mp_p->route_rvp == NULLVP) {
237 ROUTEFS_UNLOCK();
238 error = EACCES;
239 goto out;
240 }
241 ROUTEFS_UNLOCK();
242 }
243 if (vnode_getwithvid(routefs_mp_p->route_rvp, routefs_mp_p->route_vpvid) != 0) {
244 /* only one in the path., since no vnodes with this, you can hold across this call */
245 ROUTEFS_LOCK();
246 if (vnode_getwithref(routefs_mp_p->route_rvp) == 0) {
247 vnode_rele(routefs_mp_p->route_rvp);
248 vnode_put(routefs_mp_p->route_rvp);
249 routefs_mp_p->route_rvp = NULLVP;
250 routefs_mp_p->route_vpvid = -1;
251 error = vnode_lookup(routefs_mp_p->route_path, FREAD | O_DIRECTORY, &routefs_mp_p->route_rvp, ctx);
252 if (error == 0) {
253 routefs_mp_p->route_vpvid = vnode_vid(routefs_mp_p->route_rvp);
254 }
255 } else {
256 error = EACCES;
257 }
258 ROUTEFS_UNLOCK();
259
260 if (error != 0) {
261 goto out;
262 }
263 }
264 *vpp = routefs_mp_p->route_rvp;
490019cf
A
265out:
266 return error;
267}
268
269static int
270routefs_statfs( struct mount *mp, struct vfsstatfs *sbp, __unused vfs_context_t ctx)
271{
272 struct routefs_mount *routefs_mp_p = (struct routefs_mount *)mp->mnt_data;
273
274 /*-
275 * Fill in the stat block.
276 */
277 //sbp->f_type = mp->mnt_vfsstat.f_type;
0a7de745 278 sbp->f_flags = 0; /* XXX */
490019cf
A
279 sbp->f_bsize = 512;
280 sbp->f_iosize = 512;
0a7de745 281 sbp->f_blocks = (sizeof(struct routefs_mount) + sbp->f_bsize) / sbp->f_bsize;
490019cf
A
282 sbp->f_bfree = 0;
283 sbp->f_bavail = 0;
284 sbp->f_files = 0;
285 sbp->f_ffree = 0;
ea3f0419 286 sbp->f_fsid.val[0] = (int32_t)VM_KERNEL_ADDRHASH(routefs_mp_p);
490019cf
A
287 sbp->f_fsid.val[1] = vfs_typenum(mp);
288
289 return 0;
290}
291
292static int
293routefs_vfs_getattr(__unused mount_t mp, struct vfs_attr *fsap, __unused vfs_context_t ctx)
294{
295 VFSATTR_RETURN(fsap, f_objcount, 1);
296 VFSATTR_RETURN(fsap, f_maxobjcount, 1);
297 VFSATTR_RETURN(fsap, f_bsize, 512);
298 VFSATTR_RETURN(fsap, f_iosize, 512);
299 if (VFSATTR_IS_ACTIVE(fsap, f_blocks) || VFSATTR_IS_ACTIVE(fsap, f_bused)) {
0a7de745 300 fsap->f_blocks = (sizeof(struct routefs_mount) + fsap->f_bsize) / fsap->f_bsize;
490019cf
A
301 fsap->f_bused = fsap->f_blocks;
302 VFSATTR_SET_SUPPORTED(fsap, f_blocks);
303 VFSATTR_SET_SUPPORTED(fsap, f_bused);
304 }
305 VFSATTR_RETURN(fsap, f_bfree, 0);
306 VFSATTR_RETURN(fsap, f_bavail, 0);
307 VFSATTR_RETURN(fsap, f_files, 0);
308 VFSATTR_RETURN(fsap, f_ffree, 0);
309 VFSATTR_RETURN(fsap, f_fssubtype, 0);
0a7de745 310
490019cf
A
311 if (VFSATTR_IS_ACTIVE(fsap, f_capabilities)) {
312 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_FORMAT] =
0a7de745
A
313 VOL_CAP_FMT_SYMBOLICLINKS |
314 VOL_CAP_FMT_HARDLINKS |
315 VOL_CAP_FMT_NO_ROOT_TIMES |
316 VOL_CAP_FMT_CASE_SENSITIVE |
317 VOL_CAP_FMT_CASE_PRESERVING |
318 VOL_CAP_FMT_FAST_STATFS |
319 VOL_CAP_FMT_2TB_FILESIZE |
320 VOL_CAP_FMT_HIDDEN_FILES;
490019cf 321 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_INTERFACES] =
0a7de745 322 VOL_CAP_INT_ATTRLIST;
490019cf
A
323 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_RESERVED1] = 0;
324 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_RESERVED2] = 0;
0a7de745 325
490019cf 326 fsap->f_capabilities.valid[VOL_CAPABILITIES_FORMAT] =
0a7de745
A
327 VOL_CAP_FMT_PERSISTENTOBJECTIDS |
328 VOL_CAP_FMT_SYMBOLICLINKS |
329 VOL_CAP_FMT_HARDLINKS |
330 VOL_CAP_FMT_JOURNAL |
331 VOL_CAP_FMT_JOURNAL_ACTIVE |
332 VOL_CAP_FMT_NO_ROOT_TIMES |
333 VOL_CAP_FMT_SPARSE_FILES |
334 VOL_CAP_FMT_ZERO_RUNS |
335 VOL_CAP_FMT_CASE_SENSITIVE |
336 VOL_CAP_FMT_CASE_PRESERVING |
337 VOL_CAP_FMT_FAST_STATFS |
338 VOL_CAP_FMT_2TB_FILESIZE |
339 VOL_CAP_FMT_OPENDENYMODES |
340 VOL_CAP_FMT_HIDDEN_FILES |
341 VOL_CAP_FMT_PATH_FROM_ID |
342 VOL_CAP_FMT_NO_VOLUME_SIZES;
490019cf 343 fsap->f_capabilities.valid[VOL_CAPABILITIES_INTERFACES] =
0a7de745
A
344 VOL_CAP_INT_SEARCHFS |
345 VOL_CAP_INT_ATTRLIST |
346 VOL_CAP_INT_NFSEXPORT |
347 VOL_CAP_INT_READDIRATTR |
348 VOL_CAP_INT_EXCHANGEDATA |
349 VOL_CAP_INT_COPYFILE |
350 VOL_CAP_INT_ALLOCATE |
351 VOL_CAP_INT_VOL_RENAME |
352 VOL_CAP_INT_ADVLOCK |
353 VOL_CAP_INT_FLOCK |
354 VOL_CAP_INT_EXTENDED_SECURITY |
355 VOL_CAP_INT_USERACCESS |
356 VOL_CAP_INT_MANLOCK |
357 VOL_CAP_INT_EXTENDED_ATTR |
358 VOL_CAP_INT_NAMEDSTREAMS;
490019cf
A
359 fsap->f_capabilities.valid[VOL_CAPABILITIES_RESERVED1] = 0;
360 fsap->f_capabilities.valid[VOL_CAPABILITIES_RESERVED2] = 0;
0a7de745 361
490019cf
A
362 VFSATTR_SET_SUPPORTED(fsap, f_capabilities);
363 }
0a7de745 364
490019cf
A
365 if (VFSATTR_IS_ACTIVE(fsap, f_attributes)) {
366 fsap->f_attributes.validattr.commonattr =
0a7de745
A
367 ATTR_CMN_NAME | ATTR_CMN_DEVID | ATTR_CMN_FSID |
368 ATTR_CMN_OBJTYPE | ATTR_CMN_OBJTAG | ATTR_CMN_OBJID |
369 ATTR_CMN_PAROBJID |
370 ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | ATTR_CMN_ACCTIME |
371 ATTR_CMN_OWNERID | ATTR_CMN_GRPID | ATTR_CMN_ACCESSMASK |
372 ATTR_CMN_FLAGS | ATTR_CMN_USERACCESS | ATTR_CMN_FILEID;
490019cf 373 fsap->f_attributes.validattr.volattr =
0a7de745
A
374 ATTR_VOL_FSTYPE | ATTR_VOL_SIZE | ATTR_VOL_SPACEFREE |
375 ATTR_VOL_SPACEAVAIL | ATTR_VOL_MINALLOCATION |
376 ATTR_VOL_OBJCOUNT | ATTR_VOL_MAXOBJCOUNT |
377 ATTR_VOL_MOUNTPOINT | ATTR_VOL_MOUNTFLAGS |
378 ATTR_VOL_MOUNTEDDEVICE | ATTR_VOL_CAPABILITIES |
379 ATTR_VOL_ATTRIBUTES;
490019cf 380 fsap->f_attributes.validattr.dirattr =
0a7de745 381 ATTR_DIR_LINKCOUNT | ATTR_DIR_MOUNTSTATUS;
490019cf 382 fsap->f_attributes.validattr.fileattr =
0a7de745
A
383 ATTR_FILE_LINKCOUNT | ATTR_FILE_TOTALSIZE |
384 ATTR_FILE_IOBLOCKSIZE | ATTR_FILE_DEVTYPE |
385 ATTR_FILE_DATALENGTH;
490019cf 386 fsap->f_attributes.validattr.forkattr = 0;
0a7de745 387
490019cf 388 fsap->f_attributes.nativeattr.commonattr =
0a7de745
A
389 ATTR_CMN_NAME | ATTR_CMN_DEVID | ATTR_CMN_FSID |
390 ATTR_CMN_OBJTYPE | ATTR_CMN_OBJTAG | ATTR_CMN_OBJID |
391 ATTR_CMN_PAROBJID |
392 ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | ATTR_CMN_ACCTIME |
393 ATTR_CMN_OWNERID | ATTR_CMN_GRPID | ATTR_CMN_ACCESSMASK |
394 ATTR_CMN_FLAGS | ATTR_CMN_USERACCESS | ATTR_CMN_FILEID;
490019cf 395 fsap->f_attributes.nativeattr.volattr =
0a7de745
A
396 ATTR_VOL_FSTYPE | ATTR_VOL_SIZE | ATTR_VOL_SPACEFREE |
397 ATTR_VOL_SPACEAVAIL | ATTR_VOL_MINALLOCATION |
398 ATTR_VOL_OBJCOUNT | ATTR_VOL_MAXOBJCOUNT |
399 ATTR_VOL_MOUNTPOINT | ATTR_VOL_MOUNTFLAGS |
400 ATTR_VOL_MOUNTEDDEVICE | ATTR_VOL_CAPABILITIES |
401 ATTR_VOL_ATTRIBUTES;
490019cf 402 fsap->f_attributes.nativeattr.dirattr =
0a7de745 403 ATTR_DIR_MOUNTSTATUS;
490019cf 404 fsap->f_attributes.nativeattr.fileattr =
0a7de745
A
405 ATTR_FILE_LINKCOUNT | ATTR_FILE_TOTALSIZE |
406 ATTR_FILE_IOBLOCKSIZE | ATTR_FILE_DEVTYPE |
407 ATTR_FILE_DATALENGTH;
490019cf
A
408 fsap->f_attributes.nativeattr.forkattr = 0;
409
410 VFSATTR_SET_SUPPORTED(fsap, f_attributes);
411 }
0a7de745 412
490019cf
A
413 return 0;
414}
415
416static int
417routefs_sync(__unused struct mount *mp, __unused int waitfor, __unused vfs_context_t ctx)
418{
0a7de745 419 return 0;
490019cf
A
420}
421
422
423static int
424routefs_vget(__unused struct mount *mp, __unused ino64_t ino, __unused struct vnode **vpp, __unused vfs_context_t ctx)
425{
426 return ENOTSUP;
427}
428
429static int
0a7de745 430routefs_fhtovp(__unused struct mount *mp, __unused int fhlen, __unused unsigned char *fhp, __unused struct vnode **vpp, __unused vfs_context_t ctx)
490019cf 431{
0a7de745 432 return EINVAL;
490019cf
A
433}
434
435
436static int
0a7de745 437routefs_vptofh(__unused struct vnode *vp, __unused int *fhlenp, __unused unsigned char *fhp, __unused vfs_context_t ctx)
490019cf 438{
0a7de745 439 return EINVAL;
490019cf
A
440}
441
442static int
443routefs_sysctl(__unused int *name, __unused u_int namelen, __unused user_addr_t oldp,
0a7de745
A
444 __unused size_t *oldlenp, __unused user_addr_t newp,
445 __unused size_t newlen, __unused vfs_context_t ctx)
490019cf 446{
0a7de745 447 return ENOTSUP;
490019cf
A
448}
449
450#include <sys/namei.h>
451#define MOBILE_DIR_PATH "/private/var/mobile"
452/*
453 * Function: routefs_kernel_mount
454 * Purpose:
455 * Mount routefs at the given mount point from within the kernel.
456 */
457int
458routefs_kernel_mount(char * routepath)
459{
0a7de745 460 int error = EINVAL;
490019cf
A
461 vfs_context_t ctx = vfs_context_kernel();
462 char fsname[] = "routefs";
0a7de745
A
463 struct routefs_args args;
464 char mounthere[] = MOBILE_DIR_PATH; /* !const because of internal casting */
465
466 bzero(&args, sizeof(struct routefs_args));
467 strlcpy(args.route_path, routepath, MAXPATHLEN);
468 error = vnode_lookup(args.route_path, FREAD | O_DIRECTORY, &args.route_rvp, ctx);
469 if (error) {
470 goto out;
490019cf
A
471 }
472
0a7de745
A
473 if (!vnode_isdir(args.route_rvp)) {
474 error = EACCES;
475 goto out;
476 }
490019cf 477
0a7de745 478 error = kernel_mount(fsname, NULLVP, NULLVP, mounthere, &args, 0, MNT_DONTBROWSE, KERNEL_MOUNT_NOAUTH, ctx);
490019cf
A
479 if (error) {
480 goto out;
481 }
482
483out:
0a7de745
A
484 if (args.route_rvp != NULLVP) {
485 (void) vnode_put(args.route_rvp);
486 }
487 return error;
490019cf
A
488}
489
cb323159 490const struct vfsops routefs_vfsops = {
490019cf
A
491 .vfs_mount = routefs_mount,
492 .vfs_start = routefs_start,
493 .vfs_unmount = routefs_unmount,
494 .vfs_root = routefs_root,
495 .vfs_getattr = routefs_vfs_getattr,
496 .vfs_sync = routefs_sync,
497 .vfs_vget = routefs_vget,
498 .vfs_fhtovp = routefs_fhtovp,
499 .vfs_vptofh = routefs_vptofh,
500 .vfs_init = routefs_init,
501 .vfs_sysctl = routefs_sysctl,
502 // There are other VFS ops that we do not support
503};
504
0a7de745
A
505static int
506routefserr_lookup(__unused struct vnop_lookup_args * args)
490019cf 507{
0a7de745 508 return ENOTSUP;
490019cf
A
509}
510
0a7de745
A
511static int
512routefserr_setlabel(__unused struct vnop_setlabel_args * args)
490019cf 513{
0a7de745 514 return ENOTSUP;
490019cf
A
515}
516
517#define VOPFUNC int (*)(void *)
518
519/* The following ops are used by directories and symlinks */
0a7de745 520int(**routefs_vnodeop_p)(void *);
cb323159
A
521static const struct vnodeopv_entry_desc routefs_vnodeop_entries[] = {
522 { .opve_op = &vnop_default_desc, .opve_impl = (VOPFUNC)vn_default_error },
523 { .opve_op = &vnop_lookup_desc, .opve_impl = (VOPFUNC)routefserr_lookup }, /* lookup */
524 { .opve_op = &vnop_create_desc, .opve_impl = (VOPFUNC)err_create }, /* create */
525 { .opve_op = &vnop_whiteout_desc, .opve_impl = (VOPFUNC)err_whiteout }, /* whiteout */
526 { .opve_op = &vnop_mknod_desc, .opve_impl = (VOPFUNC)err_mknod }, /* mknod */
527 { .opve_op = &vnop_open_desc, .opve_impl = (VOPFUNC)err_open }, /* open */
528 { .opve_op = &vnop_close_desc, .opve_impl = (VOPFUNC)err_close }, /* close */
529 { .opve_op = &vnop_getattr_desc, .opve_impl = (VOPFUNC)err_getattr }, /* getattr */
530 { .opve_op = &vnop_setattr_desc, .opve_impl = (VOPFUNC)err_setattr }, /* setattr */
531 { .opve_op = &vnop_read_desc, .opve_impl = (VOPFUNC)err_read }, /* read */
532 { .opve_op = &vnop_write_desc, .opve_impl = (VOPFUNC)err_write }, /* write */
533 { .opve_op = &vnop_ioctl_desc, .opve_impl = (VOPFUNC)err_ioctl }, /* ioctl */
534 { .opve_op = &vnop_select_desc, .opve_impl = (VOPFUNC)err_select }, /* select */
535 { .opve_op = &vnop_revoke_desc, .opve_impl = (VOPFUNC)err_revoke }, /* revoke */
536 { .opve_op = &vnop_mmap_desc, .opve_impl = (VOPFUNC)err_mmap }, /* mmap */
537 { .opve_op = &vnop_fsync_desc, .opve_impl = (VOPFUNC)nop_fsync }, /* fsync */
538 { .opve_op = &vnop_remove_desc, .opve_impl = (VOPFUNC)err_remove }, /* remove */
539 { .opve_op = &vnop_link_desc, .opve_impl = (VOPFUNC)err_link }, /* link */
540 { .opve_op = &vnop_rename_desc, .opve_impl = (VOPFUNC)err_rename }, /* rename */
541 { .opve_op = &vnop_mkdir_desc, .opve_impl = (VOPFUNC)err_mkdir }, /* mkdir */
542 { .opve_op = &vnop_rmdir_desc, .opve_impl = (VOPFUNC)err_rmdir }, /* rmdir */
543 { .opve_op = &vnop_symlink_desc, .opve_impl = (VOPFUNC)err_symlink }, /* symlink */
544 { .opve_op = &vnop_readdir_desc, .opve_impl = (VOPFUNC)err_readdir }, /* readdir */
545 { .opve_op = &vnop_readlink_desc, .opve_impl = (VOPFUNC)err_readlink }, /* readlink */
546 { .opve_op = &vnop_inactive_desc, .opve_impl = (VOPFUNC)err_inactive }, /* inactive */
547 { .opve_op = &vnop_reclaim_desc, .opve_impl = (VOPFUNC)err_reclaim }, /* reclaim */
548 { .opve_op = &vnop_strategy_desc, .opve_impl = (VOPFUNC)err_strategy }, /* strategy */
549 { .opve_op = &vnop_pathconf_desc, .opve_impl = (VOPFUNC)err_pathconf }, /* pathconf */
550 { .opve_op = &vnop_advlock_desc, .opve_impl = (VOPFUNC)err_advlock }, /* advlock */
551 { .opve_op = &vnop_bwrite_desc, .opve_impl = (VOPFUNC)err_bwrite },
552 { .opve_op = &vnop_pagein_desc, .opve_impl = (VOPFUNC)err_pagein }, /* Pagein */
553 { .opve_op = &vnop_pageout_desc, .opve_impl = (VOPFUNC)err_pageout }, /* Pageout */
554 { .opve_op = &vnop_copyfile_desc, .opve_impl = (VOPFUNC)err_copyfile }, /* Copyfile */
555 { .opve_op = &vnop_blktooff_desc, .opve_impl = (VOPFUNC)err_blktooff }, /* blktooff */
556 { .opve_op = &vnop_offtoblk_desc, .opve_impl = (VOPFUNC)err_offtoblk }, /* offtoblk */
557 { .opve_op = &vnop_blockmap_desc, .opve_impl = (VOPFUNC)err_blockmap }, /* blockmap */
490019cf 558#if CONFIG_MACF
cb323159 559 { .opve_op = &vnop_setlabel_desc, .opve_impl = (VOPFUNC)routefserr_setlabel }, /* setlabel */
490019cf 560#endif
cb323159 561 { .opve_op = (struct vnodeop_desc*)NULL, .opve_impl = (int (*)(void *))NULL }
490019cf 562};
cb323159
A
563
564const struct vnodeopv_desc routefs_vnodeop_opv_desc =
565{ .opv_desc_vector_p = &routefs_vnodeop_p, .opv_desc_ops = routefs_vnodeop_entries };