]> git.saurik.com Git - apple/xnu.git/blame - bsd/miscfs/devfs/devfs_vfsops.c
xnu-3789.1.32.tar.gz
[apple/xnu.git] / bsd / miscfs / devfs / devfs_vfsops.c
CommitLineData
1c79356b 1/*
6d2010ae 2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
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.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*-
29 * Copyright 1997,1998 Julian Elischer. All rights reserved.
30 * julian@freebsd.org
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions are
34 * met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright notice,
38 * this list of conditions and the following disclaimer in the documentation
39 * and/or other materials provided with the distribution.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
42 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44 * DISCLAIMED. IN NO EVENT SHALL THE HOLDER OR CONTRIBUTORS BE LIABLE FOR
45 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
47 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * devfs_vfsops.c
54 *
55 */
2d21ac55
A
56/*
57 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
58 * support for mandatory and extensible security protections. This notice
59 * is included in support of clause 2.2 (b) of the Apple Public License,
60 * Version 2.0.
61 */
1c79356b
A
62/*
63 * HISTORY
64 * Dieter Siegmund (dieter@apple.com) Wed Jul 14 13:37:59 PDT 1999
65 * - modified devfs_statfs() to use devfs_stats to calculate the
66 * amount of memory used by devfs
67 */
68
69
70#include <sys/param.h>
71#include <sys/systm.h>
72#include <sys/kernel.h>
91447636 73#include <sys/vnode_internal.h>
1c79356b 74#include <sys/proc.h>
91447636
A
75#include <sys/kauth.h>
76#include <sys/mount_internal.h>
1c79356b 77#include <sys/malloc.h>
39037602 78#include <sys/conf.h>
2d21ac55 79#include <libkern/OSAtomic.h>
39037602 80#include <atm/atm_internal.h>
2d21ac55
A
81
82#if CONFIG_MACF
83#include <security/mac_framework.h>
84#endif
85
1c79356b
A
86#include "devfs.h"
87#include "devfsdefs.h"
88
b0d623f7
A
89#if FDESC
90#include "fdesc.h"
91#endif /* FDESC */
92
93
2d21ac55
A
94static int devfs_statfs( struct mount *mp, struct vfsstatfs *sbp, vfs_context_t ctx);
95static int devfs_vfs_getattr(mount_t mp, struct vfs_attr *fsap, vfs_context_t ctx);
1c79356b 96
fe8ab488
A
97#if CONFIG_DEV_KMEM
98extern boolean_t dev_kmem_enabled;
6d2010ae 99#endif
1c79356b
A
100
101/*-
102 * Called from the generic VFS startups.
103 * This is the second stage of DEVFS initialisation.
104 * The probed devices have already been loaded and the
105 * basic structure of the DEVFS created.
106 * We take the oportunity to mount the hidden DEVFS layer, so that
107 * devices from devfs get sync'd.
108 */
109static int
b0d623f7 110devfs_init(__unused struct vfsconf *vfsp)
1c79356b 111{
fe8ab488
A
112 if (devfs_sinit())
113 return (ENOTSUP);
114 devfs_make_node(makedev(0, 0), DEVFS_CHAR,
115 UID_ROOT, GID_WHEEL, 0622, "console");
116 devfs_make_node(makedev(2, 0), DEVFS_CHAR,
117 UID_ROOT, GID_WHEEL, 0666, "tty");
118#if CONFIG_DEV_KMEM
119 if (dev_kmem_enabled) {
120 /* (3,0) reserved for /dev/mem physical memory */
121 devfs_make_node(makedev(3, 1), DEVFS_CHAR,
122 UID_ROOT, GID_KMEM, 0640, "kmem");
123 }
6d2010ae 124#endif
fe8ab488
A
125 devfs_make_node(makedev(3, 2), DEVFS_CHAR,
126 UID_ROOT, GID_WHEEL, 0666, "null");
127 devfs_make_node(makedev(3, 3), DEVFS_CHAR,
128 UID_ROOT, GID_WHEEL, 0666, "zero");
39037602
A
129 uint32_t logging_config = atm_get_diagnostic_config();
130
131 if ( logging_config & ATM_ENABLE_LEGACY_LOGGING ) {
132 devfs_make_node(makedev(6, 0), DEVFS_CHAR,
fe8ab488 133 UID_ROOT, GID_WHEEL, 0600, "klog");
39037602
A
134 }
135
136 if ( !(logging_config & ATM_TRACE_DISABLE) ) {
137 devfs_make_node(makedev(7, 0), DEVFS_CHAR,
138 UID_ROOT, GID_WHEEL, 0600, "oslog");
139 if (cdevsw_setkqueueok(7, (&(cdevsw[7])), 0) == -1) {
140 return (ENOTSUP);
141 }
142
143 devfs_make_node(makedev(8, 0), DEVFS_CHAR,
144 UID_ROOT, GID_WHEEL, 0600, "oslog_stream");
145 if (cdevsw_setkqueueok(8, (&(cdevsw[8])), 0) == -1) {
146 return (ENOTSUP);
147 }
148 }
149
b0d623f7
A
150
151#if FDESC
fe8ab488 152 devfs_fdesc_init();
b0d623f7
A
153#endif
154
1c79356b
A
155 return 0;
156}
157
158/*-
159 * mp - pointer to 'mount' structure
160 * path - addr in user space of mount point (ie /usr or whatever)
161 * data - addr in user space of mount params including the
162 * name of the block special file to treat as a filesystem.
163 * (NOT USED)
164 * ndp - namei data pointer (NOT USED)
165 * p - proc pointer
166 * devfs is special in that it doesn't require any device to be mounted..
167 * It makes up its data as it goes along.
168 * it must be mounted during single user.. until it is, only std{in/out/err}
169 * and the root filesystem are available.
170 */
171/*proto*/
172int
2d21ac55 173devfs_mount(struct mount *mp, __unused vnode_t devvp, __unused user_addr_t data, vfs_context_t ctx)
1c79356b
A
174{
175 struct devfsmount *devfs_mp_p; /* devfs specific mount info */
176 int error;
1c79356b
A
177
178 /*-
179 * If they just want to update, we don't need to do anything.
180 */
181 if (mp->mnt_flag & MNT_UPDATE)
182 {
183 return 0;
184 }
185
91447636
A
186 /* Advisory locking should be handled at the VFS layer */
187 vfs_setlocklocal(mp);
188
1c79356b
A
189 /*-
190 * Well, it's not an update, it's a real mount request.
191 * Time to get dirty.
192 * HERE we should check to see if we are already mounted here.
193 */
194
195 MALLOC(devfs_mp_p, struct devfsmount *, sizeof(struct devfsmount),
196 M_DEVFSMNT, M_WAITOK);
197 if (devfs_mp_p == NULL)
198 return (ENOMEM);
199 bzero(devfs_mp_p,sizeof(*devfs_mp_p));
200 devfs_mp_p->mount = mp;
201
202 /*-
203 * Fill out some fields
204 */
3e170ce0 205 __IGNORE_WCASTALIGN(mp->mnt_data = (qaddr_t)devfs_mp_p);
b0d623f7 206 mp->mnt_vfsstat.f_fsid.val[0] = (int32_t)(uintptr_t)devfs_mp_p;
91447636 207 mp->mnt_vfsstat.f_fsid.val[1] = vfs_typenum(mp);
1c79356b
A
208 mp->mnt_flag |= MNT_LOCAL;
209
91447636 210 DEVFS_LOCK();
1c79356b 211 error = dev_dup_plane(devfs_mp_p);
91447636
A
212 DEVFS_UNLOCK();
213
1c79356b
A
214 if (error) {
215 mp->mnt_data = (qaddr_t)0;
216 FREE((caddr_t)devfs_mp_p, M_DEVFSMNT);
217 return (error);
91447636
A
218 } else
219 DEVFS_INCR_MOUNTS();
1c79356b
A
220
221 /*-
222 * Copy in the name of the directory the filesystem
223 * is to be mounted on.
224 * And we clear the remainder of the character strings
225 * to be tidy.
226 */
227
91447636
A
228 bzero(mp->mnt_vfsstat.f_mntfromname, MAXPATHLEN);
229 bcopy("devfs",mp->mnt_vfsstat.f_mntfromname, 5);
2d21ac55 230 (void)devfs_statfs(mp, &mp->mnt_vfsstat, ctx);
91447636 231
1c79356b
A
232 return 0;
233}
234
235
236static int
2d21ac55 237devfs_start(__unused struct mount *mp, __unused int flags, __unused vfs_context_t ctx)
1c79356b
A
238{
239 return 0;
240}
241
242/*-
243 * Unmount the filesystem described by mp.
244 */
245static int
2d21ac55 246devfs_unmount( struct mount *mp, int mntflags, __unused vfs_context_t ctx)
1c79356b
A
247{
248 struct devfsmount *devfs_mp_p = (struct devfsmount *)mp->mnt_data;
249 int flags = 0;
9bccf70c 250 int force = 0;
1c79356b
A
251 int error;
252
253 if (mntflags & MNT_FORCE) {
254 flags |= FORCECLOSE;
9bccf70c 255 force = 1;
1c79356b
A
256 }
257 error = vflush(mp, NULLVP, flags);
9bccf70c 258 if (error && !force)
1c79356b
A
259 return error;
260
91447636 261 DEVFS_LOCK();
1c79356b 262 devfs_free_plane(devfs_mp_p);
91447636
A
263 DEVFS_UNLOCK();
264
1c79356b 265 DEVFS_DECR_MOUNTS();
91447636
A
266
267 FREE((caddr_t)devfs_mp_p, M_DEVFSMNT);
1c79356b
A
268 mp->mnt_data = (qaddr_t)0;
269 mp->mnt_flag &= ~MNT_LOCAL;
270
271 return 0;
272}
273
274/* return the address of the root vnode in *vpp */
275static int
2d21ac55 276devfs_root(struct mount *mp, struct vnode **vpp, __unused vfs_context_t ctx)
1c79356b
A
277{
278 struct devfsmount *devfs_mp_p = (struct devfsmount *)(mp->mnt_data);
279 int error;
280
91447636 281 DEVFS_LOCK();
2d21ac55
A
282 /* last parameter to devfs_dntovn() is ignored */
283 error = devfs_dntovn(devfs_mp_p->plane_root->de_dnp, vpp, NULL);
91447636 284 DEVFS_UNLOCK();
1c79356b 285
91447636 286 return error;
1c79356b
A
287}
288
289static int
2d21ac55 290devfs_statfs( struct mount *mp, struct vfsstatfs *sbp, __unused vfs_context_t ctx)
1c79356b
A
291{
292 struct devfsmount *devfs_mp_p = (struct devfsmount *)mp->mnt_data;
293
294 /*-
295 * Fill in the stat block.
296 */
91447636 297 //sbp->f_type = mp->mnt_vfsstat.f_type;
1c79356b
A
298 sbp->f_flags = 0; /* XXX */
299 sbp->f_bsize = 512;
300 sbp->f_iosize = 512;
301 sbp->f_blocks = (devfs_stats.mounts * sizeof(struct devfsmount)
302 + devfs_stats.nodes * sizeof(devnode_t)
303 + devfs_stats.entries * sizeof(devdirent_t)
304 + devfs_stats.stringspace
305 ) / sbp->f_bsize;
306 sbp->f_bfree = 0;
307 sbp->f_bavail = 0;
308 sbp->f_files = devfs_stats.nodes;
309 sbp->f_ffree = 0;
b0d623f7 310 sbp->f_fsid.val[0] = (int32_t)(uintptr_t)devfs_mp_p;
91447636 311 sbp->f_fsid.val[1] = vfs_typenum(mp);
1c79356b 312
91447636
A
313 return 0;
314}
315
316static int
2d21ac55 317devfs_vfs_getattr(__unused mount_t mp, struct vfs_attr *fsap, __unused vfs_context_t ctx)
91447636
A
318{
319 VFSATTR_RETURN(fsap, f_objcount, devfs_stats.nodes);
320 VFSATTR_RETURN(fsap, f_maxobjcount, devfs_stats.nodes);
321 VFSATTR_RETURN(fsap, f_bsize, 512);
322 VFSATTR_RETURN(fsap, f_iosize, 512);
323 if (VFSATTR_IS_ACTIVE(fsap, f_blocks) || VFSATTR_IS_ACTIVE(fsap, f_bused)) {
324 fsap->f_blocks = (devfs_stats.mounts * sizeof(struct devfsmount)
325 + devfs_stats.nodes * sizeof(devnode_t)
326 + devfs_stats.entries * sizeof(devdirent_t)
327 + devfs_stats.stringspace
328 ) / fsap->f_bsize;
329 fsap->f_bused = fsap->f_blocks;
330 VFSATTR_SET_SUPPORTED(fsap, f_blocks);
331 VFSATTR_SET_SUPPORTED(fsap, f_bused);
1c79356b 332 }
91447636
A
333 VFSATTR_RETURN(fsap, f_bfree, 0);
334 VFSATTR_RETURN(fsap, f_bavail, 0);
335 VFSATTR_RETURN(fsap, f_files, devfs_stats.nodes);
336 VFSATTR_RETURN(fsap, f_ffree, 0);
337 VFSATTR_RETURN(fsap, f_fssubtype, 0);
338
b0d623f7
A
339 if (VFSATTR_IS_ACTIVE(fsap, f_capabilities)) {
340 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_FORMAT] =
341 VOL_CAP_FMT_SYMBOLICLINKS |
342 VOL_CAP_FMT_HARDLINKS |
343 VOL_CAP_FMT_NO_ROOT_TIMES |
344 VOL_CAP_FMT_CASE_SENSITIVE |
345 VOL_CAP_FMT_CASE_PRESERVING |
346 VOL_CAP_FMT_FAST_STATFS |
347 VOL_CAP_FMT_2TB_FILESIZE |
348 VOL_CAP_FMT_HIDDEN_FILES;
349 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_INTERFACES] =
350 VOL_CAP_INT_ATTRLIST ;
351 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_RESERVED1] = 0;
352 fsap->f_capabilities.capabilities[VOL_CAPABILITIES_RESERVED2] = 0;
353
354 fsap->f_capabilities.valid[VOL_CAPABILITIES_FORMAT] =
355 VOL_CAP_FMT_PERSISTENTOBJECTIDS |
356 VOL_CAP_FMT_SYMBOLICLINKS |
357 VOL_CAP_FMT_HARDLINKS |
358 VOL_CAP_FMT_JOURNAL |
359 VOL_CAP_FMT_JOURNAL_ACTIVE |
360 VOL_CAP_FMT_NO_ROOT_TIMES |
361 VOL_CAP_FMT_SPARSE_FILES |
362 VOL_CAP_FMT_ZERO_RUNS |
363 VOL_CAP_FMT_CASE_SENSITIVE |
364 VOL_CAP_FMT_CASE_PRESERVING |
365 VOL_CAP_FMT_FAST_STATFS |
366 VOL_CAP_FMT_2TB_FILESIZE |
367 VOL_CAP_FMT_OPENDENYMODES |
368 VOL_CAP_FMT_HIDDEN_FILES |
369 VOL_CAP_FMT_PATH_FROM_ID |
370 VOL_CAP_FMT_NO_VOLUME_SIZES;
371 fsap->f_capabilities.valid[VOL_CAPABILITIES_INTERFACES] =
372 VOL_CAP_INT_SEARCHFS |
373 VOL_CAP_INT_ATTRLIST |
374 VOL_CAP_INT_NFSEXPORT |
375 VOL_CAP_INT_READDIRATTR |
376 VOL_CAP_INT_EXCHANGEDATA |
377 VOL_CAP_INT_COPYFILE |
378 VOL_CAP_INT_ALLOCATE |
379 VOL_CAP_INT_VOL_RENAME |
380 VOL_CAP_INT_ADVLOCK |
381 VOL_CAP_INT_FLOCK |
382 VOL_CAP_INT_EXTENDED_SECURITY |
383 VOL_CAP_INT_USERACCESS |
384 VOL_CAP_INT_MANLOCK |
385 VOL_CAP_INT_EXTENDED_ATTR |
386 VOL_CAP_INT_NAMEDSTREAMS;
387 fsap->f_capabilities.valid[VOL_CAPABILITIES_RESERVED1] = 0;
388 fsap->f_capabilities.valid[VOL_CAPABILITIES_RESERVED2] = 0;
389
390 VFSATTR_SET_SUPPORTED(fsap, f_capabilities);
391 }
392
393 if (VFSATTR_IS_ACTIVE(fsap, f_attributes)) {
394 fsap->f_attributes.validattr.commonattr =
395 ATTR_CMN_NAME | ATTR_CMN_DEVID | ATTR_CMN_FSID |
396 ATTR_CMN_OBJTYPE | ATTR_CMN_OBJTAG | ATTR_CMN_OBJID |
397 ATTR_CMN_PAROBJID |
398 ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | ATTR_CMN_ACCTIME |
399 ATTR_CMN_OWNERID | ATTR_CMN_GRPID | ATTR_CMN_ACCESSMASK |
400 ATTR_CMN_FLAGS | ATTR_CMN_USERACCESS | ATTR_CMN_FILEID;
401 fsap->f_attributes.validattr.volattr =
402 ATTR_VOL_FSTYPE | ATTR_VOL_SIZE | ATTR_VOL_SPACEFREE |
403 ATTR_VOL_SPACEAVAIL | ATTR_VOL_MINALLOCATION |
404 ATTR_VOL_OBJCOUNT | ATTR_VOL_MAXOBJCOUNT |
405 ATTR_VOL_MOUNTPOINT | ATTR_VOL_MOUNTFLAGS |
406 ATTR_VOL_MOUNTEDDEVICE | ATTR_VOL_CAPABILITIES |
407 ATTR_VOL_ATTRIBUTES;
408 fsap->f_attributes.validattr.dirattr =
409 ATTR_DIR_LINKCOUNT | ATTR_DIR_MOUNTSTATUS;
410 fsap->f_attributes.validattr.fileattr =
411 ATTR_FILE_LINKCOUNT | ATTR_FILE_TOTALSIZE |
412 ATTR_FILE_IOBLOCKSIZE | ATTR_FILE_DEVTYPE |
413 ATTR_FILE_DATALENGTH;
414 fsap->f_attributes.validattr.forkattr = 0;
415
416 fsap->f_attributes.nativeattr.commonattr =
417 ATTR_CMN_NAME | ATTR_CMN_DEVID | ATTR_CMN_FSID |
418 ATTR_CMN_OBJTYPE | ATTR_CMN_OBJTAG | ATTR_CMN_OBJID |
419 ATTR_CMN_PAROBJID |
420 ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | ATTR_CMN_ACCTIME |
421 ATTR_CMN_OWNERID | ATTR_CMN_GRPID | ATTR_CMN_ACCESSMASK |
422 ATTR_CMN_FLAGS | ATTR_CMN_USERACCESS | ATTR_CMN_FILEID;
423 fsap->f_attributes.nativeattr.volattr =
424 ATTR_VOL_FSTYPE | ATTR_VOL_SIZE | ATTR_VOL_SPACEFREE |
425 ATTR_VOL_SPACEAVAIL | ATTR_VOL_MINALLOCATION |
426 ATTR_VOL_OBJCOUNT | ATTR_VOL_MAXOBJCOUNT |
427 ATTR_VOL_MOUNTPOINT | ATTR_VOL_MOUNTFLAGS |
428 ATTR_VOL_MOUNTEDDEVICE | ATTR_VOL_CAPABILITIES |
429 ATTR_VOL_ATTRIBUTES;
430 fsap->f_attributes.nativeattr.dirattr =
431 ATTR_DIR_MOUNTSTATUS;
432 fsap->f_attributes.nativeattr.fileattr =
433 ATTR_FILE_LINKCOUNT | ATTR_FILE_TOTALSIZE |
434 ATTR_FILE_IOBLOCKSIZE | ATTR_FILE_DEVTYPE |
435 ATTR_FILE_DATALENGTH;
436 fsap->f_attributes.nativeattr.forkattr = 0;
437
438 VFSATTR_SET_SUPPORTED(fsap, f_attributes);
439 }
440
1c79356b
A
441 return 0;
442}
443
444static int
2d21ac55 445devfs_sync(__unused struct mount *mp, __unused int waitfor, __unused vfs_context_t ctx)
1c79356b
A
446{
447 return (0);
448}
449
450
451static int
2d21ac55 452devfs_vget(__unused struct mount *mp, __unused ino64_t ino, __unused struct vnode **vpp, __unused vfs_context_t ctx)
1c79356b 453{
91447636 454 return ENOTSUP;
1c79356b
A
455}
456
457/*************************************************************
458 * The concept of exporting a kernel generated devfs is stupid
459 * So don't handle filehandles
460 */
461
462static int
2d21ac55 463devfs_fhtovp (__unused struct mount *mp, __unused int fhlen, __unused unsigned char *fhp, __unused struct vnode **vpp, __unused vfs_context_t ctx)
1c79356b
A
464{
465 return (EINVAL);
466}
467
468
469static int
2d21ac55 470devfs_vptofh (__unused struct vnode *vp, __unused int *fhlenp, __unused unsigned char *fhp, __unused vfs_context_t ctx)
1c79356b
A
471{
472 return (EINVAL);
473}
474
475static int
91447636
A
476devfs_sysctl(__unused int *name, __unused u_int namelen, __unused user_addr_t oldp,
477 __unused size_t *oldlenp, __unused user_addr_t newp,
2d21ac55 478 __unused size_t newlen, __unused vfs_context_t ctx)
1c79356b 479{
91447636 480 return (ENOTSUP);
1c79356b
A
481}
482
483#include <sys/namei.h>
484
485/*
486 * Function: devfs_kernel_mount
487 * Purpose:
488 * Mount devfs at the given mount point from within the kernel.
489 */
490int
491devfs_kernel_mount(char * mntname)
492{
1c79356b 493 int error;
2d21ac55 494 vfs_context_t ctx = vfs_context_kernel();
fe8ab488 495 char fsname[] = "devfs";
1c79356b 496
fe8ab488 497 error = kernel_mount(fsname, NULLVP, NULLVP, mntname, NULL, 0, MNT_DONTBROWSE, KERNEL_MOUNT_NOAUTH, ctx);
1c79356b 498 if (error) {
fe8ab488
A
499 printf("devfs_kernel_mount: kernel_mount failed: %d\n", error);
500 return (error);
1c79356b 501 }
fe8ab488 502
1c79356b
A
503 return (0);
504}
505
506struct vfsops devfs_vfsops = {
39037602
A
507 .vfs_mount = devfs_mount,
508 .vfs_start = devfs_start,
509 .vfs_unmount = devfs_unmount,
510 .vfs_root = devfs_root,
511 .vfs_getattr = devfs_vfs_getattr,
512 .vfs_sync = devfs_sync,
513 .vfs_vget = devfs_vget,
514 .vfs_fhtovp = devfs_fhtovp,
515 .vfs_vptofh = devfs_vptofh,
516 .vfs_init = devfs_init,
517 .vfs_sysctl = devfs_sysctl,
518 // There are other VFS ops that we do not support
1c79356b 519};