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