2 * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright 1997,1998 Julian Elischer. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions are
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.
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
58 * Clark Warner (warner_c@apple.com) Tue Feb 10 2000
59 * - Added err_copyfile to the vnode operations table
60 * Dieter Siegmund (dieter@apple.com) Thu Apr 8 14:08:19 PDT 1999
61 * - instead of duplicating specfs here, created a vnode-ops table
62 * that redirects most operations to specfs (as is done with ufs);
63 * - removed routines that made no sense
64 * - cleaned up reclaim: replaced devfs_vntodn() with a macro VTODN()
65 * - cleaned up symlink, link locking
66 * - added the devfs_lock to protect devfs data structures against
67 * driver's calling devfs_add_devswf()/etc.
68 * Dieter Siegmund (dieter@apple.com) Wed Jul 14 13:37:59 PDT 1999
69 * - free the devfs devnode in devfs_inactive(), not just in devfs_reclaim()
70 * to free up kernel memory as soon as it's available
71 * - got rid of devfsspec_{read, write}
72 * Dieter Siegmund (dieter@apple.com) Fri Sep 17 09:58:38 PDT 1999
73 * - update the mod/access times
76 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
77 * support for mandatory and extensible security protections. This notice
78 * is included in support of clause 2.2 (b) of the Apple Public License,
82 #include <sys/param.h>
83 #include <sys/systm.h>
84 #include <sys/namei.h>
85 #include <sys/kernel.h>
86 #include <sys/fcntl.h>
88 #include <sys/disklabel.h>
91 #include <sys/mount_internal.h>
93 #include <sys/kauth.h>
95 #include <sys/vnode_internal.h>
96 #include <miscfs/specfs/specdev.h>
97 #include <sys/dirent.h>
98 #include <sys/vmmeter.h>
100 #include <sys/uio_internal.h>
103 #include <security/mac_framework.h>
106 #include "devfsdefs.h"
113 static int devfs_update(struct vnode
*vp
, struct timeval
*access
,
114 struct timeval
*modify
);
115 void devfs_rele_node(devnode_t
*);
116 static void devfs_consider_time_update(devnode_t
*dnp
, uint32_t just_changed_flags
);
117 static boolean_t
devfs_update_needed(long now_s
, long last_s
);
118 void dn_times_locked(devnode_t
* dnp
, struct timeval
*t1
, struct timeval
*t2
, struct timeval
*t3
, uint32_t just_changed_flags
);
119 void dn_times_now(devnode_t
*dnp
, uint32_t just_changed_flags
);
120 void dn_mark_for_delayed_times_update(devnode_t
*dnp
, uint32_t just_changed_flags
);
123 dn_times_locked(devnode_t
* dnp
, struct timeval
*t1
, struct timeval
*t2
, struct timeval
*t3
, uint32_t just_changed_flags
)
126 lck_mtx_assert(&devfs_attr_mutex
, LCK_MTX_ASSERT_OWNED
);
128 if (just_changed_flags
& DEVFS_UPDATE_ACCESS
) {
129 dnp
->dn_atime
.tv_sec
= t1
->tv_sec
;
130 dnp
->dn_atime
.tv_nsec
= t1
->tv_usec
* 1000;
132 } else if (dnp
->dn_access
) {
133 dnp
->dn_atime
.tv_sec
= MIN(t1
->tv_sec
, dnp
->dn_atime
.tv_sec
+ DEVFS_LAZY_UPDATE_SECONDS
);
134 dnp
->dn_atime
.tv_nsec
= t1
->tv_usec
* 1000;
138 if (just_changed_flags
& DEVFS_UPDATE_MOD
) {
139 dnp
->dn_mtime
.tv_sec
= t2
->tv_sec
;
140 dnp
->dn_mtime
.tv_nsec
= t2
->tv_usec
* 1000;
142 } else if (dnp
->dn_update
) {
143 dnp
->dn_mtime
.tv_sec
= MIN(t2
->tv_sec
, dnp
->dn_mtime
.tv_sec
+ DEVFS_LAZY_UPDATE_SECONDS
);
144 dnp
->dn_mtime
.tv_nsec
= t2
->tv_usec
* 1000;
148 if (just_changed_flags
& DEVFS_UPDATE_CHANGE
) {
149 dnp
->dn_ctime
.tv_sec
= t3
->tv_sec
;
150 dnp
->dn_ctime
.tv_nsec
= t3
->tv_usec
* 1000;
152 } else if (dnp
->dn_change
) {
153 dnp
->dn_ctime
.tv_sec
= MIN(t3
->tv_sec
, dnp
->dn_ctime
.tv_sec
+ DEVFS_LAZY_UPDATE_SECONDS
);
154 dnp
->dn_ctime
.tv_nsec
= t3
->tv_usec
* 1000;
160 dn_mark_for_delayed_times_update(devnode_t
*dnp
, uint32_t just_changed_flags
)
162 if (just_changed_flags
& DEVFS_UPDATE_CHANGE
) {
165 if (just_changed_flags
& DEVFS_UPDATE_ACCESS
) {
168 if (just_changed_flags
& DEVFS_UPDATE_MOD
) {
174 * Update times based on pending updates and optionally a set of new changes.
177 dn_times_now(devnode_t
* dnp
, uint32_t just_changed_flags
)
181 DEVFS_ATTR_LOCK_SPIN();
183 dn_times_locked(dnp
, &now
, &now
, &now
, just_changed_flags
);
189 * Convert a component of a pathname into a pointer to a locked node.
190 * This is a very central and rather complicated routine.
191 * If the file system is not maintained in a strict tree hierarchy,
192 * this can result in a deadlock situation (see comments in code below).
194 * The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on
195 * whether the name is to be looked up, created, renamed, or deleted.
196 * When CREATE, RENAME, or DELETE is specified, information usable in
197 * creating, renaming, or deleting a directory entry may be calculated.
198 * If flag has LOCKPARENT or'ed into it and the target of the pathname
199 * exists, lookup returns both the target and its parent directory locked.
200 * When creating or renaming and LOCKPARENT is specified, the target may
201 * not be ".". When deleting and LOCKPARENT is specified, the target may
202 * be "."., but the caller must check to ensure it does an vrele and DNUNLOCK
203 * instead of two DNUNLOCKs.
205 * Overall outline of devfs_lookup:
207 * check accessibility of directory
208 * null terminate the component (lookup leaves the whole string alone)
209 * look for name in cache, if found, then if at end of path
210 * and deleting or creating, drop it, else return name
211 * search for name in directory, to found or notfound
213 * if creating, return locked directory,
216 * if at end of path and deleting, return information to allow delete
217 * if at end of path and rewriting (RENAME and LOCKPARENT), lock target
218 * node and return info to allow rewrite
219 * if not at end, add name to cache; if at end and neither creating
220 * nor deleting, add name to cache
221 * On return to lookup, remove the null termination we put in at the start.
223 * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent node unlocked.
226 devfs_lookup(struct vnop_lookup_args
*ap
)
227 /*struct vnop_lookup_args {
228 struct vnode * a_dvp; directory vnode ptr
229 struct vnode ** a_vpp; where to put the result
230 struct componentname * a_cnp; the name we want
231 vfs_context_t a_context;
234 struct componentname
*cnp
= ap
->a_cnp
;
235 vfs_context_t ctx
= cnp
->cn_context
;
236 struct proc
*p
= vfs_context_proc(ctx
);
237 struct vnode
*dir_vnode
= ap
->a_dvp
;
238 struct vnode
**result_vnode
= ap
->a_vpp
;
239 devnode_t
* dir_node
; /* the directory we are searching */
240 devnode_t
* node
= NULL
; /* the node we are searching for */
241 devdirent_t
* nodename
;
242 int flags
= cnp
->cn_flags
;
243 int op
= cnp
->cn_nameiop
; /* LOOKUP, CREATE, RENAME, or DELETE */
244 int wantparent
= flags
& (LOCKPARENT
|WANTPARENT
);
246 char heldchar
; /* the char at the end of the name componet */
250 *result_vnode
= NULL
; /* safe not sorry */ /*XXX*/
252 /* okay to look at directory vnodes ourside devfs lock as they are not aliased */
253 dir_node
= VTODN(dir_vnode
);
256 * Make sure that our node is a directory as well.
258 if (dir_node
->dn_type
!= DEV_DIR
) {
264 * temporarily terminate string component
266 heldchar
= cnp
->cn_nameptr
[cnp
->cn_namelen
];
267 cnp
->cn_nameptr
[cnp
->cn_namelen
] = '\0';
269 nodename
= dev_findname(dir_node
, cnp
->cn_nameptr
);
271 * restore saved character
273 cnp
->cn_nameptr
[cnp
->cn_namelen
] = heldchar
;
277 node
= nodename
->de_dnp
;
279 /* Do potential vnode allocation here inside the lock
280 * to make sure that our device node has a non-NULL dn_vn
281 * associated with it. The device node might otherwise
282 * get deleted out from under us (see devfs_dn_free()).
284 error
= devfs_dntovn(node
, result_vnode
, p
);
295 * we haven't called devfs_dntovn if we get here
296 * we have not taken a reference on the node.. no
297 * vnode_put is necessary on these error returns
299 * If it doesn't exist and we're not the last component,
300 * or we're at the last component, but we're not creating
301 * or renaming, return ENOENT.
303 if (!(flags
& ISLASTCN
) || !(op
== CREATE
|| op
== RENAME
)) {
307 * We return with the directory locked, so that
308 * the parameters we set up above will still be
309 * valid if we actually decide to add a new entry.
310 * We return ni_vp == NULL to indicate that the entry
311 * does not currently exist; we leave a pointer to
312 * the (locked) directory vnode in namei_data->ni_dvp.
314 * NB - if the directory is unlocked, then this
315 * information cannot be used.
317 return (EJUSTRETURN
);
320 * from this point forward, we need to vnode_put the reference
321 * picked up in devfs_dntovn if we decide to return an error
325 * If deleting, and at end of pathname, return
326 * parameters which can be used to remove file.
327 * If the wantparent flag isn't set, we return only
328 * the directory (in namei_data->ni_dvp), otherwise we go
329 * on and lock the node, being careful with ".".
331 if (op
== DELETE
&& (flags
& ISLASTCN
)) {
334 * we are trying to delete '.'. What does this mean? XXX
336 if (dir_node
== node
) {
338 vnode_put(*result_vnode
);
339 *result_vnode
= NULL
;
341 if ( ((error
= vnode_get(dir_vnode
)) == 0) ) {
342 *result_vnode
= dir_vnode
;
350 * If rewriting (RENAME), return the vnode and the
351 * information required to rewrite the present directory
352 * Must get node of directory entry to verify it's a
353 * regular file, or empty directory.
355 if (op
== RENAME
&& wantparent
&& (flags
& ISLASTCN
)) {
358 * Careful about locking second node.
359 * This can only occur if the target is ".".
361 if (dir_node
== node
) {
369 * Step through the translation in the name. We do not unlock the
370 * directory because we may need it again if a symbolic link
371 * is relative to the current directory. Instead we save it
372 * unlocked as "saved_dir_node" XXX. We must get the target
373 * node before unlocking
374 * the directory to insure that the node will not be removed
375 * before we get it. We prevent deadlock by always fetching
376 * nodes from the root, moving down the directory tree. Thus
377 * when following backward pointers ".." we must unlock the
378 * parent directory before getting the requested directory.
379 * There is a potential race condition here if both the current
380 * and parent directories are removed before the lock for the
381 * node associated with ".." returns. We hope that this occurs
382 * infrequently since we cannot avoid this race condition without
383 * implementing a sophisticated deadlock detection algorithm.
384 * Note also that this simple deadlock detection scheme will not
385 * work if the file system has any hard links other than ".."
386 * that point backwards in the directory structure.
388 if ((flags
& ISDOTDOT
) == 0 && dir_node
== node
) {
390 vnode_put(*result_vnode
);
391 *result_vnode
= NULL
;
393 if ( (error
= vnode_get(dir_vnode
)) ) {
396 *result_vnode
= dir_vnode
;
402 vnode_put(*result_vnode
);
403 *result_vnode
= NULL
;
409 devfs_getattr(struct vnop_getattr_args
*ap
)
410 /*struct vnop_getattr_args {
412 struct vnode_attr *a_vap;
417 struct vnode
*vp
= ap
->a_vp
;
418 struct vnode_attr
*vap
= ap
->a_vap
;
419 devnode_t
* file_node
;
424 file_node
= VTODN(vp
);
426 VATTR_RETURN(vap
, va_mode
, file_node
->dn_mode
);
429 * Note: for DEV_CDEV and DEV_BDEV, we return the device from
430 * the vp, not the file_node; if we getting information on a
431 * cloning device, we want the cloned information, not the template.
433 switch (file_node
->dn_type
)
437 case DEV_DEVFD
: /* Like a directory */
439 VATTR_RETURN(vap
, va_rdev
, 0);
440 vap
->va_mode
|= (S_IFDIR
);
443 VATTR_RETURN(vap
, va_rdev
, vp
->v_rdev
);
444 vap
->va_mode
|= (S_IFCHR
);
447 VATTR_RETURN(vap
, va_rdev
, vp
->v_rdev
);
448 vap
->va_mode
|= (S_IFBLK
);
451 VATTR_RETURN(vap
, va_rdev
, 0);
452 vap
->va_mode
|= (S_IFLNK
);
455 VATTR_RETURN(vap
, va_rdev
, 0); /* default value only */
457 VATTR_RETURN(vap
, va_type
, vp
->v_type
);
458 VATTR_RETURN(vap
, va_nlink
, file_node
->dn_links
);
459 VATTR_RETURN(vap
, va_uid
, file_node
->dn_uid
);
460 VATTR_RETURN(vap
, va_gid
, file_node
->dn_gid
);
461 VATTR_RETURN(vap
, va_fsid
, (uintptr_t)file_node
->dn_dvm
);
462 VATTR_RETURN(vap
, va_fileid
, (uintptr_t)file_node
->dn_ino
);
463 VATTR_RETURN(vap
, va_data_size
, file_node
->dn_len
);
465 /* return an override block size (advisory) */
466 if (vp
->v_type
== VBLK
)
467 VATTR_RETURN(vap
, va_iosize
, BLKDEV_IOSIZE
);
468 else if (vp
->v_type
== VCHR
)
469 VATTR_RETURN(vap
, va_iosize
, MAXPHYSIO
);
471 VATTR_RETURN(vap
, va_iosize
, vp
->v_mount
->mnt_vfsstat
.f_iosize
);
474 DEVFS_ATTR_LOCK_SPIN();
477 dn_times_locked(file_node
, &now
, &now
, &now
, 0);
479 /* if the time is bogus, set it to the boot time */
480 if (file_node
->dn_ctime
.tv_sec
== 0) {
481 file_node
->dn_ctime
.tv_sec
= boottime_sec();
482 file_node
->dn_ctime
.tv_nsec
= 0;
484 if (file_node
->dn_mtime
.tv_sec
== 0)
485 file_node
->dn_mtime
= file_node
->dn_ctime
;
486 if (file_node
->dn_atime
.tv_sec
== 0)
487 file_node
->dn_atime
= file_node
->dn_ctime
;
488 VATTR_RETURN(vap
, va_change_time
, file_node
->dn_ctime
);
489 VATTR_RETURN(vap
, va_modify_time
, file_node
->dn_mtime
);
490 VATTR_RETURN(vap
, va_access_time
, file_node
->dn_atime
);
494 VATTR_RETURN(vap
, va_gen
, 0);
495 VATTR_RETURN(vap
, va_filerev
, 0);
496 VATTR_RETURN(vap
, va_acl
, NULL
);
498 /* Hide the root so Finder doesn't display it */
499 if (vnode_isvroot(vp
)) {
500 VATTR_RETURN(vap
, va_flags
, UF_HIDDEN
);
502 VATTR_RETURN(vap
, va_flags
, 0);
511 devfs_setattr(struct vnop_setattr_args
*ap
)
512 /*struct vnop_setattr_args {
514 struct vnode_attr *a_vap;
515 vfs_context_t a_context;
518 struct vnode
*vp
= ap
->a_vp
;
519 struct vnode_attr
*vap
= ap
->a_vap
;
521 devnode_t
* file_node
;
522 struct timeval atimeval
, mtimeval
;
526 file_node
= VTODN(vp
);
528 * Go through the fields and update if set.
530 if (VATTR_IS_ACTIVE(vap
, va_access_time
) || VATTR_IS_ACTIVE(vap
, va_modify_time
)) {
533 if (VATTR_IS_ACTIVE(vap
, va_access_time
))
534 file_node
->dn_access
= 1;
535 if (VATTR_IS_ACTIVE(vap
, va_modify_time
)) {
536 file_node
->dn_change
= 1;
537 file_node
->dn_update
= 1;
539 atimeval
.tv_sec
= vap
->va_access_time
.tv_sec
;
540 atimeval
.tv_usec
= vap
->va_access_time
.tv_nsec
/ 1000;
541 mtimeval
.tv_sec
= vap
->va_modify_time
.tv_sec
;
542 mtimeval
.tv_usec
= vap
->va_modify_time
.tv_nsec
/ 1000;
544 if ( (error
= devfs_update(vp
, &atimeval
, &mtimeval
)) )
547 VATTR_SET_SUPPORTED(vap
, va_access_time
);
548 VATTR_SET_SUPPORTED(vap
, va_change_time
);
551 * Change the permissions.
553 if (VATTR_IS_ACTIVE(vap
, va_mode
)) {
554 file_node
->dn_mode
&= ~07777;
555 file_node
->dn_mode
|= vap
->va_mode
& 07777;
557 VATTR_SET_SUPPORTED(vap
, va_mode
);
562 if (VATTR_IS_ACTIVE(vap
, va_uid
))
563 file_node
->dn_uid
= vap
->va_uid
;
564 VATTR_SET_SUPPORTED(vap
, va_uid
);
569 if (VATTR_IS_ACTIVE(vap
, va_gid
))
570 file_node
->dn_gid
= vap
->va_gid
;
571 VATTR_SET_SUPPORTED(vap
, va_gid
);
580 devfs_setlabel(struct vnop_setlabel_args
*ap
)
581 /* struct vnop_setlabel_args {
582 struct vnodeop_desc *a_desc;
585 vfs_context_t a_context;
594 mac_vnode_label_update(ap
->a_context
, vp
, ap
->a_vl
);
595 mac_devfs_label_update(vp
->v_mount
, de
, vp
);
602 devfs_read(struct vnop_read_args
*ap
)
603 /* struct vnop_read_args {
607 vfs_context_t a_context;
610 devnode_t
* dn_p
= VTODN(ap
->a_vp
);
612 switch (ap
->a_vp
->v_type
) {
616 return VNOP_READDIR(ap
->a_vp
, ap
->a_uio
, 0, NULL
, NULL
, ap
->a_context
);
619 printf("devfs_read(): bad file type %d", ap
->a_vp
->v_type
);
626 devfs_close(struct vnop_close_args
*ap
)
627 /* struct vnop_close_args {
630 vfs_context_t a_context;
633 struct vnode
* vp
= ap
->a_vp
;
636 if (vnode_isinuse(vp
, 1)) {
640 dn_times_now(dnp
, 0);
647 devfsspec_close(struct vnop_close_args
*ap
)
648 /* struct vnop_close_args {
651 vfs_context_t a_context;
654 struct vnode
* vp
= ap
->a_vp
;
657 if (vnode_isinuse(vp
, 0)) {
661 dn_times_now(dnp
, 0);
665 return (VOCALL (spec_vnodeop_p
, VOFFSET(vnop_close
), ap
));
669 devfs_update_needed(long now_s
, long last_s
)
671 if (now_s
> last_s
) {
672 if (now_s
- last_s
>= DEVFS_LAZY_UPDATE_SECONDS
) {
681 * Given a set of time updates required [to happen at some point], check
682 * either make those changes (and resolve other pending updates) or mark
683 * the devnode for a subsequent update.
686 devfs_consider_time_update(devnode_t
*dnp
, uint32_t just_changed_flags
)
694 if (dnp
->dn_change
|| (just_changed_flags
& DEVFS_UPDATE_CHANGE
)) {
695 if (devfs_update_needed(now_s
, dnp
->dn_ctime
.tv_sec
)) {
696 dn_times_now(dnp
, just_changed_flags
);
700 if (dnp
->dn_access
|| (just_changed_flags
& DEVFS_UPDATE_ACCESS
)) {
701 if (devfs_update_needed(now_s
, dnp
->dn_atime
.tv_sec
)) {
702 dn_times_now(dnp
, just_changed_flags
);
706 if (dnp
->dn_update
|| (just_changed_flags
& DEVFS_UPDATE_MOD
)) {
707 if (devfs_update_needed(now_s
, dnp
->dn_mtime
.tv_sec
)) {
708 dn_times_now(dnp
, just_changed_flags
);
713 /* Not going to do anything now--mark for later update */
714 dn_mark_for_delayed_times_update(dnp
, just_changed_flags
);
720 devfsspec_read(struct vnop_read_args
*ap
)
721 /* struct vnop_read_args {
728 devnode_t
* dnp
= VTODN(ap
->a_vp
);
730 devfs_consider_time_update(dnp
, DEVFS_UPDATE_ACCESS
);
732 return (VOCALL (spec_vnodeop_p
, VOFFSET(vnop_read
), ap
));
736 devfsspec_write(struct vnop_write_args
*ap
)
737 /* struct vnop_write_args {
741 vfs_context_t a_context;
744 devnode_t
* dnp
= VTODN(ap
->a_vp
);
746 devfs_consider_time_update(dnp
, DEVFS_UPDATE_CHANGE
| DEVFS_UPDATE_MOD
);
748 return (VOCALL (spec_vnodeop_p
, VOFFSET(vnop_write
), ap
));
752 * Write data to a file or directory.
755 devfs_write(struct vnop_write_args
*ap
)
756 /* struct vnop_write_args {
763 switch (ap
->a_vp
->v_type
) {
767 printf("devfs_write(): bad file type %d", ap
->a_vp
->v_type
);
773 * Deviates from UFS naming convention because there is a KPI function
774 * called devfs_remove().
777 devfs_vnop_remove(struct vnop_remove_args
*ap
)
778 /* struct vnop_remove_args {
781 struct componentname *a_cnp;
784 struct vnode
*vp
= ap
->a_vp
;
785 struct vnode
*dvp
= ap
->a_dvp
;
786 struct componentname
*cnp
= ap
->a_cnp
;
790 int doingdirectory
= 0;
794 * assume that the name is null terminated as they
795 * are the end of the path. Get pointers to all our
804 tnp
= dev_findname(tdp
, cnp
->cn_nameptr
);
812 * Make sure that we don't try do something stupid
814 if ((tp
->dn_type
) == DEV_DIR
) {
816 * Avoid ".", "..", and aliases of "." for obvious reasons.
818 if ( (cnp
->cn_namelen
== 1 && cnp
->cn_nameptr
[0] == '.')
819 || (cnp
->cn_flags
&ISDOTDOT
) ) {
826 /***********************************
827 * Start actually doing things.... *
828 ***********************************/
829 devfs_consider_time_update(tdp
, DEVFS_UPDATE_CHANGE
| DEVFS_UPDATE_MOD
);
832 * Target must be empty if a directory and have no links
833 * to it. Also, ensure source and target are compatible
834 * (both directories, or both not directories).
836 if (( doingdirectory
) && (tp
->dn_links
> 2)) {
850 devfs_link(struct vnop_link_args
*ap
)
851 /*struct vnop_link_args {
852 struct vnode *a_tdvp;
854 struct componentname *a_cnp;
855 vfs_context_t a_context;
858 struct vnode
*vp
= ap
->a_vp
;
859 struct vnode
*tdvp
= ap
->a_tdvp
;
860 struct componentname
*cnp
= ap
->a_cnp
;
867 * First catch an arbitrary restriction for this FS
869 if (cnp
->cn_namelen
> DEVMAXNAMESIZE
) {
870 error
= ENAMETOOLONG
;
875 * Lock our directories and get our name pointers
876 * assume that the names are null terminated as they
877 * are the end of the path. Get pointers to all our
880 /* can lookup dnode safely for tdvp outside of devfs lock as it is not aliased */
883 if (tdvp
->v_mount
!= vp
->v_mount
) {
890 /***********************************
891 * Start actually doing things.... *
892 ***********************************/
893 dn_times_now(fp
, DEVFS_UPDATE_CHANGE
);
896 error
= dev_add_name(cnp
->cn_nameptr
, tdp
, NULL
, fp
, &tnp
);
905 * Rename system call. Seems overly complicated to me...
906 * rename("foo", "bar");
909 * link("foo", "bar");
911 * but ``atomically''.
913 * When the target exists, both the directory
914 * and target vnodes are locked.
915 * the source and source-parent vnodes are referenced
918 * Basic algorithm is:
920 * 1) Bump link count on source while we're linking it to the
921 * target. This also ensure the inode won't be deleted out
922 * from underneath us while we work (it may be truncated by
923 * a concurrent `trunc' or `open' for creation).
924 * 2) Link source to destination. If destination already exists,
926 * 3) Unlink source reference to node if still around. If a
927 * directory was moved and the parent of the destination
928 * is different from the source, patch the ".." entry in the
932 devfs_rename(struct vnop_rename_args
*ap
)
933 /*struct vnop_rename_args {
934 struct vnode *a_fdvp;
936 struct componentname *a_fcnp;
937 struct vnode *a_tdvp;
939 struct componentname *a_tcnp;
940 vfs_context_t a_context;
943 struct vnode
*tvp
= ap
->a_tvp
;
944 struct vnode
*tdvp
= ap
->a_tdvp
;
945 struct vnode
*fvp
= ap
->a_fvp
;
946 struct vnode
*fdvp
= ap
->a_fdvp
;
947 struct componentname
*tcnp
= ap
->a_tcnp
;
948 struct componentname
*fcnp
= ap
->a_fcnp
;
949 devnode_t
*fp
, *fdp
, *tp
, *tdp
;
950 devdirent_t
*fnp
,*tnp
;
951 int doingdirectory
= 0;
956 * First catch an arbitrary restriction for this FS
958 if (tcnp
->cn_namelen
> DEVMAXNAMESIZE
) {
959 error
= ENAMETOOLONG
;
964 * assume that the names are null terminated as they
965 * are the end of the path. Get pointers to all our
972 fnp
= dev_findname(fdp
, fcnp
->cn_nameptr
);
982 tnp
= dev_findname(tdp
, tcnp
->cn_nameptr
);
992 * Make sure that we don't try do something stupid
994 if ((fp
->dn_type
) == DEV_DIR
) {
996 * Avoid ".", "..", and aliases of "." for obvious reasons.
998 if ((fcnp
->cn_namelen
== 1 && fcnp
->cn_nameptr
[0] == '.')
999 || (fcnp
->cn_flags
&ISDOTDOT
)
1000 || (tcnp
->cn_namelen
== 1 && tcnp
->cn_nameptr
[0] == '.')
1001 || (tcnp
->cn_flags
&ISDOTDOT
)
1010 * If ".." must be changed (ie the directory gets a new
1011 * parent) then the source directory must not be in the
1012 * directory hierarchy above the target, as this would
1013 * orphan everything below the source directory. Also
1014 * the user must have write permission in the source so
1015 * as to be able to change "..".
1017 if (doingdirectory
&& (tdp
!= fdp
)) {
1018 devnode_t
* tmp
, *ntmp
;
1022 /* XXX unlock stuff here probably */
1027 } while ((tmp
= tmp
->dn_typeinfo
.Dir
.parent
) != ntmp
);
1030 /***********************************
1031 * Start actually doing things.... *
1032 ***********************************/
1033 dn_times_now(fp
, DEVFS_UPDATE_CHANGE
);
1036 * Check if just deleting a link name.
1039 if (fvp
->v_type
== VDIR
) {
1043 /* Release destination completely. */
1050 * 1) Bump link count while we're moving stuff
1051 * around. If we crash somewhere before
1052 * completing our work, too bad :)
1056 * If the target exists zap it (unless it's a non-empty directory)
1057 * We could do that as well but won't
1061 * Target must be empty if a directory and have no links
1062 * to it. Also, ensure source and target are compatible
1063 * (both directories, or both not directories).
1065 if (( doingdirectory
) && (tp
->dn_links
> 2)) {
1072 dev_add_name(tcnp
->cn_nameptr
,tdp
,NULL
,fp
,&tnp
);
1074 fp
->dn_links
--; /* one less link to it.. */
1078 fp
->dn_links
--; /* we added one earlier*/
1085 devfs_mkdir(struct vnop_mkdir_args
*ap
)
1086 /*struct vnop_mkdir_args {
1087 struct vnode *a_dvp;
1088 struct vnode **a_vpp;
1089 struct componentname *a_cnp;
1090 struct vnode_attr *a_vap;
1091 vfs_context_t a_context;
1094 struct componentname
* cnp
= ap
->a_cnp
;
1095 vfs_context_t ctx
= cnp
->cn_context
;
1096 struct proc
*p
= vfs_context_proc(ctx
);
1101 struct vnode_attr
* vap
= ap
->a_vap
;
1102 struct vnode
* * vpp
= ap
->a_vpp
;
1106 dir_p
= VTODN(ap
->a_dvp
);
1107 error
= dev_add_entry(cnp
->cn_nameptr
, dir_p
, DEV_DIR
,
1108 NULL
, NULL
, NULL
, &nm_p
);
1112 dev_p
= nm_p
->de_dnp
;
1113 dev_p
->dn_uid
= dir_p
->dn_uid
;
1114 dev_p
->dn_gid
= dir_p
->dn_gid
;
1115 dev_p
->dn_mode
= vap
->va_mode
;
1116 dn_copy_times(dev_p
, dir_p
);
1118 error
= devfs_dntovn(dev_p
, vpp
, p
);
1126 * An rmdir is a special type of remove, which we already support; we wrap
1127 * and reexpress the arguments to call devfs_remove directly. The only
1128 * different argument is flags, which we do not set, since it's ignored.
1131 devfs_rmdir(struct vnop_rmdir_args
*ap
)
1132 /* struct vnop_rmdir_args {
1133 struct vnode *a_dvp;
1135 struct componentname *a_cnp;
1136 vfs_context_t a_context;
1139 struct vnop_remove_args ra
;
1141 ra
.a_dvp
= ap
->a_dvp
;
1143 ra
.a_cnp
= ap
->a_cnp
;
1144 ra
.a_flags
= 0; /* XXX */
1145 ra
.a_context
= ap
->a_context
;
1147 return devfs_vnop_remove(&ra
);
1152 devfs_symlink(struct vnop_symlink_args
*ap
)
1153 /*struct vnop_symlink_args {
1154 struct vnode *a_dvp;
1155 struct vnode **a_vpp;
1156 struct componentname *a_cnp;
1157 struct vnode_attr *a_vap;
1159 vfs_context_t a_context;
1163 devdirent_t
*newent
;
1166 error
= devfs_make_symlink(VTODN(ap
->a_dvp
), ap
->a_cnp
->cn_nameptr
, ap
->a_vap
->va_mode
, ap
->a_target
, &newent
);
1169 error
= devfs_dntovn(newent
->de_dnp
, ap
->a_vpp
, vfs_context_proc(ap
->a_context
));
1178 /* Called with devfs locked */
1180 devfs_make_symlink(devnode_t
*dir_p
, char *name
, int mode
, char *target
, devdirent_t
**newent
)
1183 devnode_type_t typeinfo
;
1187 typeinfo
.Slnk
.name
= target
;
1188 typeinfo
.Slnk
.namelen
= strlen(target
);
1190 error
= dev_add_entry(name
, dir_p
, DEV_SLNK
,
1191 &typeinfo
, NULL
, NULL
, &nm_p
);
1195 dev_p
= nm_p
->de_dnp
;
1196 dev_p
->dn_uid
= dir_p
->dn_uid
;
1197 dev_p
->dn_gid
= dir_p
->dn_gid
;
1198 dev_p
->dn_mode
= mode
;
1199 dn_copy_times(dev_p
, dir_p
);
1214 devfs_mknod(struct vnop_mknod_args
*ap
)
1215 /* struct vnop_mknod_args {
1216 struct vnode *a_dvp;
1217 struct vnode **a_vpp;
1218 struct componentname *a_cnp;
1219 struct vnode_attr *a_vap;
1220 vfs_context_t a_context;
1223 struct componentname
* cnp
= ap
->a_cnp
;
1224 vfs_context_t ctx
= cnp
->cn_context
;
1225 struct proc
*p
= vfs_context_proc(ctx
);
1227 devdirent_t
* devent
;
1228 devnode_t
* dir_p
; /* devnode for parent directory */
1229 struct vnode
* dvp
= ap
->a_dvp
;
1231 devnode_type_t typeinfo
;
1232 struct vnode_attr
* vap
= ap
->a_vap
;
1233 struct vnode
** vpp
= ap
->a_vpp
;
1236 if (!(vap
->va_type
== VBLK
) && !(vap
->va_type
== VCHR
)) {
1237 return (EINVAL
); /* only support mknod of special files */
1239 typeinfo
.dev
= vap
->va_rdev
;
1245 error
= dev_add_entry(cnp
->cn_nameptr
, dir_p
,
1246 (vap
->va_type
== VBLK
) ? DEV_BDEV
: DEV_CDEV
,
1247 &typeinfo
, NULL
, NULL
, &devent
);
1251 dev_p
= devent
->de_dnp
;
1252 error
= devfs_dntovn(dev_p
, vpp
, p
);
1255 dev_p
->dn_uid
= vap
->va_uid
;
1256 dev_p
->dn_gid
= vap
->va_gid
;
1257 dev_p
->dn_mode
= vap
->va_mode
;
1258 VATTR_SET_SUPPORTED(vap
, va_uid
);
1259 VATTR_SET_SUPPORTED(vap
, va_gid
);
1260 VATTR_SET_SUPPORTED(vap
, va_mode
);
1268 * Vnode op for readdir
1271 devfs_readdir(struct vnop_readdir_args
*ap
)
1272 /*struct vnop_readdir_args {
1278 vfs_context_t a_context;
1281 struct vnode
*vp
= ap
->a_vp
;
1282 struct uio
*uio
= ap
->a_uio
;
1283 struct dirent dirent
;
1284 devnode_t
* dir_node
;
1285 devdirent_t
* name_node
;
1292 if (ap
->a_flags
& (VNODE_READDIR_EXTENDED
| VNODE_READDIR_REQSEEKOFF
))
1295 /* set up refs to dir */
1296 dir_node
= VTODN(vp
);
1297 if (dir_node
->dn_type
!= DEV_DIR
)
1300 startpos
= uio
->uio_offset
;
1304 name_node
= dir_node
->dn_typeinfo
.Dir
.dirlist
;
1307 while ((name_node
|| (nodenumber
< 2)) && (uio_resid(uio
) > 0))
1312 dirent
.d_fileno
= dir_node
->dn_ino
;
1314 dirent
.d_namlen
= 1;
1315 dirent
.d_type
= DT_DIR
;
1318 if(dir_node
->dn_typeinfo
.Dir
.parent
)
1319 dirent
.d_fileno
= dir_node
->dn_typeinfo
.Dir
.parent
->dn_ino
;
1321 dirent
.d_fileno
= dir_node
->dn_ino
;
1323 dirent
.d_namlen
= 2;
1324 dirent
.d_type
= DT_DIR
;
1327 dirent
.d_fileno
= name_node
->de_dnp
->dn_ino
;
1328 dirent
.d_namlen
= strlen(name_node
->de_name
);
1329 name
= name_node
->de_name
;
1330 switch(name_node
->de_dnp
->dn_type
) {
1332 dirent
.d_type
= DT_BLK
;
1335 dirent
.d_type
= DT_CHR
;
1338 dirent
.d_type
= DT_DIR
;
1341 dirent
.d_type
= DT_LNK
;
1344 dirent
.d_type
= DT_UNKNOWN
;
1347 #define GENERIC_DIRSIZ(dp) \
1348 ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
1350 reclen
= dirent
.d_reclen
= GENERIC_DIRSIZ(&dirent
);
1352 if(pos
>= startpos
) /* made it to the offset yet? */
1354 if (uio_resid(uio
) < reclen
) /* will it fit? */
1356 strlcpy(dirent
.d_name
, name
, DEVMAXNAMESIZE
);
1357 if ((error
= uiomove ((caddr_t
)&dirent
,
1358 dirent
.d_reclen
, uio
)) != 0)
1362 if((nodenumber
>1) && name_node
)
1363 name_node
= name_node
->de_next
;
1367 uio
->uio_offset
= pos
;
1369 devfs_consider_time_update(dir_node
, DEVFS_UPDATE_ACCESS
);
1378 devfs_readlink(struct vnop_readlink_args
*ap
)
1379 /*struct vnop_readlink_args {
1382 vfs_context_t a_context;
1385 struct vnode
*vp
= ap
->a_vp
;
1386 struct uio
*uio
= ap
->a_uio
;
1387 devnode_t
* lnk_node
;
1390 /* set up refs to dir */
1391 lnk_node
= VTODN(vp
);
1393 if (lnk_node
->dn_type
!= DEV_SLNK
) {
1397 error
= uiomove(lnk_node
->dn_typeinfo
.Slnk
.name
,
1398 lnk_node
->dn_typeinfo
.Slnk
.namelen
, uio
);
1404 devfs_reclaim(struct vnop_reclaim_args
*ap
)
1405 /*struct vnop_reclaim_args {
1409 struct vnode
* vp
= ap
->a_vp
;
1417 /* If this is a cloning device, it didn't have a dn_vn anyway */
1419 vnode_clearfsnode(vp
);
1421 /* This could delete the node, if we are the last vnode */
1422 devfs_rele_node(dnp
);
1431 * Get configurable pathname variables.
1435 struct vnop_pathconf_args
/* {
1439 vfs_context_t a_context;
1442 switch (ap
->a_name
) {
1444 /* arbitrary limit matching HFS; devfs has no hard limit */
1445 *ap
->a_retval
= 32767;
1448 *ap
->a_retval
= DEVMAXNAMESIZE
- 1; /* includes NUL */
1451 *ap
->a_retval
= DEVMAXPATHSIZE
- 1; /* XXX nonconformant */
1453 case _PC_CHOWN_RESTRICTED
:
1454 *ap
->a_retval
= 200112; /* _POSIX_CHOWN_RESTRICTED */
1459 case _PC_CASE_SENSITIVE
:
1462 case _PC_CASE_PRESERVING
:
1474 /**************************************************************************\
1476 \**************************************************************************/
1480 * struct vnop_inactive_args {
1481 * struct vnode *a_vp;
1482 * vfs_context_t a_context;
1487 devfs_inactive(__unused
struct vnop_inactive_args
*ap
)
1489 vnode_t vp
= ap
->a_vp
;
1490 devnode_t
*dnp
= VTODN(vp
);
1493 * Cloned vnodes are not linked in anywhere, so they
1494 * can just be recycled.
1496 if (dnp
->dn_clone
!= NULL
) {
1504 * called with DEVFS_LOCK held
1507 devfs_update(struct vnode
*vp
, struct timeval
*access
, struct timeval
*modify
)
1513 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
1521 DEVFS_ATTR_LOCK_SPIN();
1523 dn_times_locked(ip
, access
, modify
, &now
, DEVFS_UPDATE_ACCESS
| DEVFS_UPDATE_MOD
);
1524 DEVFS_ATTR_UNLOCK();
1529 #define VOPFUNC int (*)(void *)
1531 /* The following ops are used by directories and symlinks */
1532 int (**devfs_vnodeop_p
)(void *);
1533 static struct vnodeopv_entry_desc devfs_vnodeop_entries
[] = {
1534 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
1535 { &vnop_lookup_desc
, (VOPFUNC
)devfs_lookup
}, /* lookup */
1536 { &vnop_create_desc
, (VOPFUNC
)err_create
}, /* create */
1537 { &vnop_whiteout_desc
, (VOPFUNC
)err_whiteout
}, /* whiteout */
1538 { &vnop_mknod_desc
, (VOPFUNC
)devfs_mknod
}, /* mknod */
1539 { &vnop_open_desc
, (VOPFUNC
)nop_open
}, /* open */
1540 { &vnop_close_desc
, (VOPFUNC
)devfs_close
}, /* close */
1541 { &vnop_getattr_desc
, (VOPFUNC
)devfs_getattr
}, /* getattr */
1542 { &vnop_setattr_desc
, (VOPFUNC
)devfs_setattr
}, /* setattr */
1543 { &vnop_read_desc
, (VOPFUNC
)devfs_read
}, /* read */
1544 { &vnop_write_desc
, (VOPFUNC
)devfs_write
}, /* write */
1545 { &vnop_ioctl_desc
, (VOPFUNC
)err_ioctl
}, /* ioctl */
1546 { &vnop_select_desc
, (VOPFUNC
)err_select
}, /* select */
1547 { &vnop_revoke_desc
, (VOPFUNC
)err_revoke
}, /* revoke */
1548 { &vnop_mmap_desc
, (VOPFUNC
)err_mmap
}, /* mmap */
1549 { &vnop_fsync_desc
, (VOPFUNC
)nop_fsync
}, /* fsync */
1550 { &vnop_remove_desc
, (VOPFUNC
)devfs_vnop_remove
}, /* remove */
1551 { &vnop_link_desc
, (VOPFUNC
)devfs_link
}, /* link */
1552 { &vnop_rename_desc
, (VOPFUNC
)devfs_rename
}, /* rename */
1553 { &vnop_mkdir_desc
, (VOPFUNC
)devfs_mkdir
}, /* mkdir */
1554 { &vnop_rmdir_desc
, (VOPFUNC
)devfs_rmdir
}, /* rmdir */
1555 { &vnop_symlink_desc
, (VOPFUNC
)devfs_symlink
}, /* symlink */
1556 { &vnop_readdir_desc
, (VOPFUNC
)devfs_readdir
}, /* readdir */
1557 { &vnop_readlink_desc
, (VOPFUNC
)devfs_readlink
}, /* readlink */
1558 { &vnop_inactive_desc
, (VOPFUNC
)devfs_inactive
}, /* inactive */
1559 { &vnop_reclaim_desc
, (VOPFUNC
)devfs_reclaim
}, /* reclaim */
1560 { &vnop_strategy_desc
, (VOPFUNC
)err_strategy
}, /* strategy */
1561 { &vnop_pathconf_desc
, (VOPFUNC
)devs_vnop_pathconf
}, /* pathconf */
1562 { &vnop_advlock_desc
, (VOPFUNC
)err_advlock
}, /* advlock */
1563 { &vnop_bwrite_desc
, (VOPFUNC
)err_bwrite
},
1564 { &vnop_pagein_desc
, (VOPFUNC
)err_pagein
}, /* Pagein */
1565 { &vnop_pageout_desc
, (VOPFUNC
)err_pageout
}, /* Pageout */
1566 { &vnop_copyfile_desc
, (VOPFUNC
)err_copyfile
}, /* Copyfile */
1567 { &vnop_blktooff_desc
, (VOPFUNC
)err_blktooff
}, /* blktooff */
1568 { &vnop_offtoblk_desc
, (VOPFUNC
)err_offtoblk
}, /* offtoblk */
1569 { &vnop_blockmap_desc
, (VOPFUNC
)err_blockmap
}, /* blockmap */
1571 { &vnop_setlabel_desc
, (VOPFUNC
)devfs_setlabel
}, /* setlabel */
1573 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
1575 struct vnodeopv_desc devfs_vnodeop_opv_desc
=
1576 { &devfs_vnodeop_p
, devfs_vnodeop_entries
};
1578 /* The following ops are used by the device nodes */
1579 int (**devfs_spec_vnodeop_p
)(void *);
1580 static struct vnodeopv_entry_desc devfs_spec_vnodeop_entries
[] = {
1581 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
1582 { &vnop_lookup_desc
, (VOPFUNC
)spec_lookup
}, /* lookup */
1583 { &vnop_create_desc
, (VOPFUNC
)spec_create
}, /* create */
1584 { &vnop_mknod_desc
, (VOPFUNC
)spec_mknod
}, /* mknod */
1585 { &vnop_open_desc
, (VOPFUNC
)spec_open
}, /* open */
1586 { &vnop_close_desc
, (VOPFUNC
)devfsspec_close
}, /* close */
1587 { &vnop_getattr_desc
, (VOPFUNC
)devfs_getattr
}, /* getattr */
1588 { &vnop_setattr_desc
, (VOPFUNC
)devfs_setattr
}, /* setattr */
1589 { &vnop_read_desc
, (VOPFUNC
)devfsspec_read
}, /* read */
1590 { &vnop_write_desc
, (VOPFUNC
)devfsspec_write
}, /* write */
1591 { &vnop_ioctl_desc
, (VOPFUNC
)spec_ioctl
}, /* ioctl */
1592 { &vnop_select_desc
, (VOPFUNC
)spec_select
}, /* select */
1593 { &vnop_revoke_desc
, (VOPFUNC
)spec_revoke
}, /* revoke */
1594 { &vnop_mmap_desc
, (VOPFUNC
)spec_mmap
}, /* mmap */
1595 { &vnop_fsync_desc
, (VOPFUNC
)spec_fsync
}, /* fsync */
1596 { &vnop_remove_desc
, (VOPFUNC
)devfs_vnop_remove
}, /* remove */
1597 { &vnop_link_desc
, (VOPFUNC
)devfs_link
}, /* link */
1598 { &vnop_rename_desc
, (VOPFUNC
)spec_rename
}, /* rename */
1599 { &vnop_mkdir_desc
, (VOPFUNC
)spec_mkdir
}, /* mkdir */
1600 { &vnop_rmdir_desc
, (VOPFUNC
)spec_rmdir
}, /* rmdir */
1601 { &vnop_symlink_desc
, (VOPFUNC
)spec_symlink
}, /* symlink */
1602 { &vnop_readdir_desc
, (VOPFUNC
)spec_readdir
}, /* readdir */
1603 { &vnop_readlink_desc
, (VOPFUNC
)spec_readlink
}, /* readlink */
1604 { &vnop_inactive_desc
, (VOPFUNC
)devfs_inactive
}, /* inactive */
1605 { &vnop_reclaim_desc
, (VOPFUNC
)devfs_reclaim
}, /* reclaim */
1606 { &vnop_strategy_desc
, (VOPFUNC
)spec_strategy
}, /* strategy */
1607 { &vnop_pathconf_desc
, (VOPFUNC
)spec_pathconf
}, /* pathconf */
1608 { &vnop_advlock_desc
, (VOPFUNC
)spec_advlock
}, /* advlock */
1609 { &vnop_bwrite_desc
, (VOPFUNC
)vn_bwrite
},
1610 { &vnop_pagein_desc
, (VOPFUNC
)err_pagein
}, /* Pagein */
1611 { &vnop_pageout_desc
, (VOPFUNC
)err_pageout
}, /* Pageout */
1612 { &vnop_copyfile_desc
, (VOPFUNC
)err_copyfile
}, /* Copyfile */
1613 { &vnop_blktooff_desc
, (VOPFUNC
)spec_blktooff
}, /* blktooff */
1614 { &vnop_blktooff_desc
, (VOPFUNC
)spec_offtoblk
}, /* blkofftoblk */
1615 { &vnop_blockmap_desc
, (VOPFUNC
)spec_blockmap
}, /* blockmap */
1617 { &vnop_setlabel_desc
, (VOPFUNC
)devfs_setlabel
}, /* setlabel */
1619 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
1621 struct vnodeopv_desc devfs_spec_vnodeop_opv_desc
=
1622 { &devfs_spec_vnodeop_p
, devfs_spec_vnodeop_entries
};
1626 int (**devfs_devfd_vnodeop_p
)(void*);
1627 static struct vnodeopv_entry_desc devfs_devfd_vnodeop_entries
[] = {
1628 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
1629 { &vnop_lookup_desc
, (VOPFUNC
)devfs_devfd_lookup
}, /* lookup */
1630 { &vnop_open_desc
, (VOPFUNC
)nop_open
}, /* open */
1631 { &vnop_close_desc
, (VOPFUNC
)devfs_close
}, /* close */
1632 { &vnop_getattr_desc
, (VOPFUNC
)devfs_getattr
}, /* getattr */
1633 { &vnop_setattr_desc
, (VOPFUNC
)devfs_setattr
}, /* setattr */
1634 { &vnop_revoke_desc
, (VOPFUNC
)err_revoke
}, /* revoke */
1635 { &vnop_fsync_desc
, (VOPFUNC
)nop_fsync
}, /* fsync */
1636 { &vnop_readdir_desc
, (VOPFUNC
)devfs_devfd_readdir
}, /* readdir */
1637 { &vnop_inactive_desc
, (VOPFUNC
)devfs_inactive
}, /* inactive */
1638 { &vnop_reclaim_desc
, (VOPFUNC
)devfs_reclaim
}, /* reclaim */
1639 { &vnop_pathconf_desc
, (VOPFUNC
)devs_vnop_pathconf
}, /* pathconf */
1641 { &vnop_setlabel_desc
, (VOPFUNC
)devfs_setlabel
}, /* setlabel */
1643 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
1645 struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc
=
1646 { &devfs_devfd_vnodeop_p
, devfs_devfd_vnodeop_entries
};