2 * Copyright (c) 2000-2007 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
);
624 return (0); /* not reached */
628 devfs_close(struct vnop_close_args
*ap
)
629 /* struct vnop_close_args {
632 vfs_context_t a_context;
635 struct vnode
* vp
= ap
->a_vp
;
636 register devnode_t
* dnp
;
638 if (vnode_isinuse(vp
, 1)) {
641 dn_times_now(dnp
, 0);
648 devfsspec_close(struct vnop_close_args
*ap
)
649 /* struct vnop_close_args {
652 vfs_context_t a_context;
655 struct vnode
* vp
= ap
->a_vp
;
656 register devnode_t
* dnp
;
658 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 register 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 register 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
);
770 return 0; /* not reached */
774 * Deviates from UFS naming convention because there is a KPI function
775 * called devfs_remove().
778 devfs_vnop_remove(struct vnop_remove_args
*ap
)
779 /* struct vnop_remove_args {
782 struct componentname *a_cnp;
785 struct vnode
*vp
= ap
->a_vp
;
786 struct vnode
*dvp
= ap
->a_dvp
;
787 struct componentname
*cnp
= ap
->a_cnp
;
791 int doingdirectory
= 0;
795 * assume that the name is null terminated as they
796 * are the end of the path. Get pointers to all our
805 tnp
= dev_findname(tdp
, cnp
->cn_nameptr
);
813 * Make sure that we don't try do something stupid
815 if ((tp
->dn_type
) == DEV_DIR
) {
817 * Avoid ".", "..", and aliases of "." for obvious reasons.
819 if ( (cnp
->cn_namelen
== 1 && cnp
->cn_nameptr
[0] == '.')
820 || (cnp
->cn_flags
&ISDOTDOT
) ) {
827 /***********************************
828 * Start actually doing things.... *
829 ***********************************/
830 devfs_consider_time_update(tdp
, DEVFS_UPDATE_CHANGE
| DEVFS_UPDATE_MOD
);
833 * Target must be empty if a directory and have no links
834 * to it. Also, ensure source and target are compatible
835 * (both directories, or both not directories).
837 if (( doingdirectory
) && (tp
->dn_links
> 2)) {
851 devfs_link(struct vnop_link_args
*ap
)
852 /*struct vnop_link_args {
853 struct vnode *a_tdvp;
855 struct componentname *a_cnp;
856 vfs_context_t a_context;
859 struct vnode
*vp
= ap
->a_vp
;
860 struct vnode
*tdvp
= ap
->a_tdvp
;
861 struct componentname
*cnp
= ap
->a_cnp
;
868 * First catch an arbitrary restriction for this FS
870 if (cnp
->cn_namelen
> DEVMAXNAMESIZE
) {
871 error
= ENAMETOOLONG
;
876 * Lock our directories and get our name pointers
877 * assume that the names are null terminated as they
878 * are the end of the path. Get pointers to all our
881 /* can lookup dnode safely for tdvp outside of devfs lock as it is not aliased */
884 if (tdvp
->v_mount
!= vp
->v_mount
) {
891 /***********************************
892 * Start actually doing things.... *
893 ***********************************/
894 dn_times_now(fp
, DEVFS_UPDATE_CHANGE
);
897 error
= dev_add_name(cnp
->cn_nameptr
, tdp
, NULL
, fp
, &tnp
);
906 * Rename system call. Seems overly complicated to me...
907 * rename("foo", "bar");
910 * link("foo", "bar");
912 * but ``atomically''.
914 * When the target exists, both the directory
915 * and target vnodes are locked.
916 * the source and source-parent vnodes are referenced
919 * Basic algorithm is:
921 * 1) Bump link count on source while we're linking it to the
922 * target. This also ensure the inode won't be deleted out
923 * from underneath us while we work (it may be truncated by
924 * a concurrent `trunc' or `open' for creation).
925 * 2) Link source to destination. If destination already exists,
927 * 3) Unlink source reference to node if still around. If a
928 * directory was moved and the parent of the destination
929 * is different from the source, patch the ".." entry in the
933 devfs_rename(struct vnop_rename_args
*ap
)
934 /*struct vnop_rename_args {
935 struct vnode *a_fdvp;
937 struct componentname *a_fcnp;
938 struct vnode *a_tdvp;
940 struct componentname *a_tcnp;
941 vfs_context_t a_context;
944 struct vnode
*tvp
= ap
->a_tvp
;
945 struct vnode
*tdvp
= ap
->a_tdvp
;
946 struct vnode
*fvp
= ap
->a_fvp
;
947 struct vnode
*fdvp
= ap
->a_fdvp
;
948 struct componentname
*tcnp
= ap
->a_tcnp
;
949 struct componentname
*fcnp
= ap
->a_fcnp
;
950 devnode_t
*fp
, *fdp
, *tp
, *tdp
;
951 devdirent_t
*fnp
,*tnp
;
952 int doingdirectory
= 0;
957 * First catch an arbitrary restriction for this FS
959 if (tcnp
->cn_namelen
> DEVMAXNAMESIZE
) {
960 error
= ENAMETOOLONG
;
965 * assume that the names are null terminated as they
966 * are the end of the path. Get pointers to all our
973 fnp
= dev_findname(fdp
, fcnp
->cn_nameptr
);
983 tnp
= dev_findname(tdp
, tcnp
->cn_nameptr
);
993 * Make sure that we don't try do something stupid
995 if ((fp
->dn_type
) == DEV_DIR
) {
997 * Avoid ".", "..", and aliases of "." for obvious reasons.
999 if ((fcnp
->cn_namelen
== 1 && fcnp
->cn_nameptr
[0] == '.')
1000 || (fcnp
->cn_flags
&ISDOTDOT
)
1001 || (tcnp
->cn_namelen
== 1 && tcnp
->cn_nameptr
[0] == '.')
1002 || (tcnp
->cn_flags
&ISDOTDOT
)
1011 * If ".." must be changed (ie the directory gets a new
1012 * parent) then the source directory must not be in the
1013 * directory hierarchy above the target, as this would
1014 * orphan everything below the source directory. Also
1015 * the user must have write permission in the source so
1016 * as to be able to change "..".
1018 if (doingdirectory
&& (tdp
!= fdp
)) {
1019 devnode_t
* tmp
, *ntmp
;
1023 /* XXX unlock stuff here probably */
1028 } while ((tmp
= tmp
->dn_typeinfo
.Dir
.parent
) != ntmp
);
1031 /***********************************
1032 * Start actually doing things.... *
1033 ***********************************/
1034 dn_times_now(fp
, DEVFS_UPDATE_CHANGE
);
1037 * Check if just deleting a link name.
1040 if (fvp
->v_type
== VDIR
) {
1044 /* Release destination completely. */
1051 * 1) Bump link count while we're moving stuff
1052 * around. If we crash somewhere before
1053 * completing our work, too bad :)
1057 * If the target exists zap it (unless it's a non-empty directory)
1058 * We could do that as well but won't
1062 * Target must be empty if a directory and have no links
1063 * to it. Also, ensure source and target are compatible
1064 * (both directories, or both not directories).
1066 if (( doingdirectory
) && (tp
->dn_links
> 2)) {
1073 dev_add_name(tcnp
->cn_nameptr
,tdp
,NULL
,fp
,&tnp
);
1075 fp
->dn_links
--; /* one less link to it.. */
1079 fp
->dn_links
--; /* we added one earlier*/
1086 devfs_mkdir(struct vnop_mkdir_args
*ap
)
1087 /*struct vnop_mkdir_args {
1088 struct vnode *a_dvp;
1089 struct vnode **a_vpp;
1090 struct componentname *a_cnp;
1091 struct vnode_attr *a_vap;
1092 vfs_context_t a_context;
1095 struct componentname
* cnp
= ap
->a_cnp
;
1096 vfs_context_t ctx
= cnp
->cn_context
;
1097 struct proc
*p
= vfs_context_proc(ctx
);
1102 struct vnode_attr
* vap
= ap
->a_vap
;
1103 struct vnode
* * vpp
= ap
->a_vpp
;
1107 dir_p
= VTODN(ap
->a_dvp
);
1108 error
= dev_add_entry(cnp
->cn_nameptr
, dir_p
, DEV_DIR
,
1109 NULL
, NULL
, NULL
, &nm_p
);
1113 dev_p
= nm_p
->de_dnp
;
1114 dev_p
->dn_uid
= dir_p
->dn_uid
;
1115 dev_p
->dn_gid
= dir_p
->dn_gid
;
1116 dev_p
->dn_mode
= vap
->va_mode
;
1117 dn_copy_times(dev_p
, dir_p
);
1119 error
= devfs_dntovn(dev_p
, vpp
, p
);
1127 * An rmdir is a special type of remove, which we already support; we wrap
1128 * and reexpress the arguments to call devfs_remove directly. The only
1129 * different argument is flags, which we do not set, since it's ignored.
1132 devfs_rmdir(struct vnop_rmdir_args
*ap
)
1133 /* struct vnop_rmdir_args {
1134 struct vnode *a_dvp;
1136 struct componentname *a_cnp;
1137 vfs_context_t a_context;
1140 struct vnop_remove_args ra
;
1142 ra
.a_dvp
= ap
->a_dvp
;
1144 ra
.a_cnp
= ap
->a_cnp
;
1145 ra
.a_flags
= 0; /* XXX */
1146 ra
.a_context
= ap
->a_context
;
1148 return devfs_vnop_remove(&ra
);
1153 devfs_symlink(struct vnop_symlink_args
*ap
)
1154 /*struct vnop_symlink_args {
1155 struct vnode *a_dvp;
1156 struct vnode **a_vpp;
1157 struct componentname *a_cnp;
1158 struct vnode_attr *a_vap;
1160 vfs_context_t a_context;
1164 devdirent_t
*newent
;
1167 error
= devfs_make_symlink(VTODN(ap
->a_dvp
), ap
->a_cnp
->cn_nameptr
, ap
->a_vap
->va_mode
, ap
->a_target
, &newent
);
1170 error
= devfs_dntovn(newent
->de_dnp
, ap
->a_vpp
, vfs_context_proc(ap
->a_context
));
1179 /* Called with devfs locked */
1181 devfs_make_symlink(devnode_t
*dir_p
, char *name
, int mode
, char *target
, devdirent_t
**newent
)
1184 devnode_type_t typeinfo
;
1188 typeinfo
.Slnk
.name
= target
;
1189 typeinfo
.Slnk
.namelen
= strlen(target
);
1191 error
= dev_add_entry(name
, dir_p
, DEV_SLNK
,
1192 &typeinfo
, NULL
, NULL
, &nm_p
);
1196 dev_p
= nm_p
->de_dnp
;
1197 dev_p
->dn_uid
= dir_p
->dn_uid
;
1198 dev_p
->dn_gid
= dir_p
->dn_gid
;
1199 dev_p
->dn_mode
= mode
;
1200 dn_copy_times(dev_p
, dir_p
);
1215 devfs_mknod(struct vnop_mknod_args
*ap
)
1216 /* struct vnop_mknod_args {
1217 struct vnode *a_dvp;
1218 struct vnode **a_vpp;
1219 struct componentname *a_cnp;
1220 struct vnode_attr *a_vap;
1221 vfs_context_t a_context;
1224 struct componentname
* cnp
= ap
->a_cnp
;
1225 vfs_context_t ctx
= cnp
->cn_context
;
1226 struct proc
*p
= vfs_context_proc(ctx
);
1228 devdirent_t
* devent
;
1229 devnode_t
* dir_p
; /* devnode for parent directory */
1230 struct vnode
* dvp
= ap
->a_dvp
;
1232 devnode_type_t typeinfo
;
1233 struct vnode_attr
* vap
= ap
->a_vap
;
1234 struct vnode
** vpp
= ap
->a_vpp
;
1237 if (!(vap
->va_type
== VBLK
) && !(vap
->va_type
== VCHR
)) {
1238 return (EINVAL
); /* only support mknod of special files */
1240 typeinfo
.dev
= vap
->va_rdev
;
1246 error
= dev_add_entry(cnp
->cn_nameptr
, dir_p
,
1247 (vap
->va_type
== VBLK
) ? DEV_BDEV
: DEV_CDEV
,
1248 &typeinfo
, NULL
, NULL
, &devent
);
1252 dev_p
= devent
->de_dnp
;
1253 error
= devfs_dntovn(dev_p
, vpp
, p
);
1256 dev_p
->dn_uid
= vap
->va_uid
;
1257 dev_p
->dn_gid
= vap
->va_gid
;
1258 dev_p
->dn_mode
= vap
->va_mode
;
1259 VATTR_SET_SUPPORTED(vap
, va_uid
);
1260 VATTR_SET_SUPPORTED(vap
, va_gid
);
1261 VATTR_SET_SUPPORTED(vap
, va_mode
);
1269 * Vnode op for readdir
1272 devfs_readdir(struct vnop_readdir_args
*ap
)
1273 /*struct vnop_readdir_args {
1279 vfs_context_t a_context;
1282 struct vnode
*vp
= ap
->a_vp
;
1283 struct uio
*uio
= ap
->a_uio
;
1284 struct dirent dirent
;
1285 devnode_t
* dir_node
;
1286 devdirent_t
* name_node
;
1293 if (ap
->a_flags
& (VNODE_READDIR_EXTENDED
| VNODE_READDIR_REQSEEKOFF
))
1296 /* set up refs to dir */
1297 dir_node
= VTODN(vp
);
1298 if (dir_node
->dn_type
!= DEV_DIR
)
1301 startpos
= uio
->uio_offset
;
1305 name_node
= dir_node
->dn_typeinfo
.Dir
.dirlist
;
1308 while ((name_node
|| (nodenumber
< 2)) && (uio_resid(uio
) > 0))
1313 dirent
.d_fileno
= dir_node
->dn_ino
;
1315 dirent
.d_namlen
= 1;
1316 dirent
.d_type
= DT_DIR
;
1319 if(dir_node
->dn_typeinfo
.Dir
.parent
)
1320 dirent
.d_fileno
= dir_node
->dn_typeinfo
.Dir
.parent
->dn_ino
;
1322 dirent
.d_fileno
= dir_node
->dn_ino
;
1324 dirent
.d_namlen
= 2;
1325 dirent
.d_type
= DT_DIR
;
1328 dirent
.d_fileno
= name_node
->de_dnp
->dn_ino
;
1329 dirent
.d_namlen
= strlen(name_node
->de_name
);
1330 name
= name_node
->de_name
;
1331 switch(name_node
->de_dnp
->dn_type
) {
1333 dirent
.d_type
= DT_BLK
;
1336 dirent
.d_type
= DT_CHR
;
1339 dirent
.d_type
= DT_DIR
;
1342 dirent
.d_type
= DT_LNK
;
1345 dirent
.d_type
= DT_UNKNOWN
;
1348 #define GENERIC_DIRSIZ(dp) \
1349 ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
1351 reclen
= dirent
.d_reclen
= GENERIC_DIRSIZ(&dirent
);
1353 if(pos
>= startpos
) /* made it to the offset yet? */
1355 if (uio_resid(uio
) < reclen
) /* will it fit? */
1357 strlcpy(dirent
.d_name
, name
, DEVMAXNAMESIZE
);
1358 if ((error
= uiomove ((caddr_t
)&dirent
,
1359 dirent
.d_reclen
, uio
)) != 0)
1363 if((nodenumber
>1) && name_node
)
1364 name_node
= name_node
->de_next
;
1368 uio
->uio_offset
= pos
;
1370 devfs_consider_time_update(dir_node
, DEVFS_UPDATE_ACCESS
);
1379 devfs_readlink(struct vnop_readlink_args
*ap
)
1380 /*struct vnop_readlink_args {
1383 vfs_context_t a_context;
1386 struct vnode
*vp
= ap
->a_vp
;
1387 struct uio
*uio
= ap
->a_uio
;
1388 devnode_t
* lnk_node
;
1391 /* set up refs to dir */
1392 lnk_node
= VTODN(vp
);
1394 if (lnk_node
->dn_type
!= DEV_SLNK
) {
1398 error
= uiomove(lnk_node
->dn_typeinfo
.Slnk
.name
,
1399 lnk_node
->dn_typeinfo
.Slnk
.namelen
, uio
);
1405 devfs_reclaim(struct vnop_reclaim_args
*ap
)
1406 /*struct vnop_reclaim_args {
1410 struct vnode
* vp
= ap
->a_vp
;
1418 /* If this is a cloning device, it didn't have a dn_vn anyway */
1420 vnode_clearfsnode(vp
);
1422 /* This could delete the node, if we are the last vnode */
1423 devfs_rele_node(dnp
);
1432 * Get configurable pathname variables.
1436 struct vnop_pathconf_args
/* {
1440 vfs_context_t a_context;
1443 switch (ap
->a_name
) {
1445 /* arbitrary limit matching HFS; devfs has no hard limit */
1446 *ap
->a_retval
= 32767;
1449 *ap
->a_retval
= DEVMAXNAMESIZE
- 1; /* includes NUL */
1452 *ap
->a_retval
= DEVMAXPATHSIZE
- 1; /* XXX nonconformant */
1454 case _PC_CHOWN_RESTRICTED
:
1455 *ap
->a_retval
= 200112; /* _POSIX_CHOWN_RESTRICTED */
1460 case _PC_CASE_SENSITIVE
:
1463 case _PC_CASE_PRESERVING
:
1475 /**************************************************************************\
1477 \**************************************************************************/
1481 * struct vnop_inactive_args {
1482 * struct vnode *a_vp;
1483 * vfs_context_t a_context;
1488 devfs_inactive(__unused
struct vnop_inactive_args
*ap
)
1490 vnode_t vp
= ap
->a_vp
;
1491 devnode_t
*dnp
= VTODN(vp
);
1494 * Cloned vnodes are not linked in anywhere, so they
1495 * can just be recycled.
1497 if (dnp
->dn_clone
!= NULL
) {
1505 * called with DEVFS_LOCK held
1508 devfs_update(struct vnode
*vp
, struct timeval
*access
, struct timeval
*modify
)
1514 if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
1522 DEVFS_ATTR_LOCK_SPIN();
1524 dn_times_locked(ip
, access
, modify
, &now
, DEVFS_UPDATE_ACCESS
| DEVFS_UPDATE_MOD
);
1525 DEVFS_ATTR_UNLOCK();
1530 #define VOPFUNC int (*)(void *)
1532 /* The following ops are used by directories and symlinks */
1533 int (**devfs_vnodeop_p
)(void *);
1534 static struct vnodeopv_entry_desc devfs_vnodeop_entries
[] = {
1535 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
1536 { &vnop_lookup_desc
, (VOPFUNC
)devfs_lookup
}, /* lookup */
1537 { &vnop_create_desc
, (VOPFUNC
)err_create
}, /* create */
1538 { &vnop_whiteout_desc
, (VOPFUNC
)err_whiteout
}, /* whiteout */
1539 { &vnop_mknod_desc
, (VOPFUNC
)devfs_mknod
}, /* mknod */
1540 { &vnop_open_desc
, (VOPFUNC
)nop_open
}, /* open */
1541 { &vnop_close_desc
, (VOPFUNC
)devfs_close
}, /* close */
1542 { &vnop_getattr_desc
, (VOPFUNC
)devfs_getattr
}, /* getattr */
1543 { &vnop_setattr_desc
, (VOPFUNC
)devfs_setattr
}, /* setattr */
1544 { &vnop_read_desc
, (VOPFUNC
)devfs_read
}, /* read */
1545 { &vnop_write_desc
, (VOPFUNC
)devfs_write
}, /* write */
1546 { &vnop_ioctl_desc
, (VOPFUNC
)err_ioctl
}, /* ioctl */
1547 { &vnop_select_desc
, (VOPFUNC
)err_select
}, /* select */
1548 { &vnop_revoke_desc
, (VOPFUNC
)err_revoke
}, /* revoke */
1549 { &vnop_mmap_desc
, (VOPFUNC
)err_mmap
}, /* mmap */
1550 { &vnop_fsync_desc
, (VOPFUNC
)nop_fsync
}, /* fsync */
1551 { &vnop_remove_desc
, (VOPFUNC
)devfs_vnop_remove
}, /* remove */
1552 { &vnop_link_desc
, (VOPFUNC
)devfs_link
}, /* link */
1553 { &vnop_rename_desc
, (VOPFUNC
)devfs_rename
}, /* rename */
1554 { &vnop_mkdir_desc
, (VOPFUNC
)devfs_mkdir
}, /* mkdir */
1555 { &vnop_rmdir_desc
, (VOPFUNC
)devfs_rmdir
}, /* rmdir */
1556 { &vnop_symlink_desc
, (VOPFUNC
)devfs_symlink
}, /* symlink */
1557 { &vnop_readdir_desc
, (VOPFUNC
)devfs_readdir
}, /* readdir */
1558 { &vnop_readlink_desc
, (VOPFUNC
)devfs_readlink
}, /* readlink */
1559 { &vnop_inactive_desc
, (VOPFUNC
)devfs_inactive
}, /* inactive */
1560 { &vnop_reclaim_desc
, (VOPFUNC
)devfs_reclaim
}, /* reclaim */
1561 { &vnop_strategy_desc
, (VOPFUNC
)err_strategy
}, /* strategy */
1562 { &vnop_pathconf_desc
, (VOPFUNC
)devs_vnop_pathconf
}, /* pathconf */
1563 { &vnop_advlock_desc
, (VOPFUNC
)err_advlock
}, /* advlock */
1564 { &vnop_bwrite_desc
, (VOPFUNC
)err_bwrite
},
1565 { &vnop_pagein_desc
, (VOPFUNC
)err_pagein
}, /* Pagein */
1566 { &vnop_pageout_desc
, (VOPFUNC
)err_pageout
}, /* Pageout */
1567 { &vnop_copyfile_desc
, (VOPFUNC
)err_copyfile
}, /* Copyfile */
1568 { &vnop_blktooff_desc
, (VOPFUNC
)err_blktooff
}, /* blktooff */
1569 { &vnop_offtoblk_desc
, (VOPFUNC
)err_offtoblk
}, /* offtoblk */
1570 { &vnop_blockmap_desc
, (VOPFUNC
)err_blockmap
}, /* blockmap */
1572 { &vnop_setlabel_desc
, (VOPFUNC
)devfs_setlabel
}, /* setlabel */
1574 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
1576 struct vnodeopv_desc devfs_vnodeop_opv_desc
=
1577 { &devfs_vnodeop_p
, devfs_vnodeop_entries
};
1579 /* The following ops are used by the device nodes */
1580 int (**devfs_spec_vnodeop_p
)(void *);
1581 static struct vnodeopv_entry_desc devfs_spec_vnodeop_entries
[] = {
1582 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
1583 { &vnop_lookup_desc
, (VOPFUNC
)spec_lookup
}, /* lookup */
1584 { &vnop_create_desc
, (VOPFUNC
)spec_create
}, /* create */
1585 { &vnop_mknod_desc
, (VOPFUNC
)spec_mknod
}, /* mknod */
1586 { &vnop_open_desc
, (VOPFUNC
)spec_open
}, /* open */
1587 { &vnop_close_desc
, (VOPFUNC
)devfsspec_close
}, /* close */
1588 { &vnop_getattr_desc
, (VOPFUNC
)devfs_getattr
}, /* getattr */
1589 { &vnop_setattr_desc
, (VOPFUNC
)devfs_setattr
}, /* setattr */
1590 { &vnop_read_desc
, (VOPFUNC
)devfsspec_read
}, /* read */
1591 { &vnop_write_desc
, (VOPFUNC
)devfsspec_write
}, /* write */
1592 { &vnop_ioctl_desc
, (VOPFUNC
)spec_ioctl
}, /* ioctl */
1593 { &vnop_select_desc
, (VOPFUNC
)spec_select
}, /* select */
1594 { &vnop_revoke_desc
, (VOPFUNC
)spec_revoke
}, /* revoke */
1595 { &vnop_mmap_desc
, (VOPFUNC
)spec_mmap
}, /* mmap */
1596 { &vnop_fsync_desc
, (VOPFUNC
)spec_fsync
}, /* fsync */
1597 { &vnop_remove_desc
, (VOPFUNC
)devfs_vnop_remove
}, /* remove */
1598 { &vnop_link_desc
, (VOPFUNC
)devfs_link
}, /* link */
1599 { &vnop_rename_desc
, (VOPFUNC
)spec_rename
}, /* rename */
1600 { &vnop_mkdir_desc
, (VOPFUNC
)spec_mkdir
}, /* mkdir */
1601 { &vnop_rmdir_desc
, (VOPFUNC
)spec_rmdir
}, /* rmdir */
1602 { &vnop_symlink_desc
, (VOPFUNC
)spec_symlink
}, /* symlink */
1603 { &vnop_readdir_desc
, (VOPFUNC
)spec_readdir
}, /* readdir */
1604 { &vnop_readlink_desc
, (VOPFUNC
)spec_readlink
}, /* readlink */
1605 { &vnop_inactive_desc
, (VOPFUNC
)devfs_inactive
}, /* inactive */
1606 { &vnop_reclaim_desc
, (VOPFUNC
)devfs_reclaim
}, /* reclaim */
1607 { &vnop_strategy_desc
, (VOPFUNC
)spec_strategy
}, /* strategy */
1608 { &vnop_pathconf_desc
, (VOPFUNC
)spec_pathconf
}, /* pathconf */
1609 { &vnop_advlock_desc
, (VOPFUNC
)spec_advlock
}, /* advlock */
1610 { &vnop_bwrite_desc
, (VOPFUNC
)vn_bwrite
},
1611 { &vnop_pagein_desc
, (VOPFUNC
)err_pagein
}, /* Pagein */
1612 { &vnop_pageout_desc
, (VOPFUNC
)err_pageout
}, /* Pageout */
1613 { &vnop_copyfile_desc
, (VOPFUNC
)err_copyfile
}, /* Copyfile */
1614 { &vnop_blktooff_desc
, (VOPFUNC
)spec_blktooff
}, /* blktooff */
1615 { &vnop_blktooff_desc
, (VOPFUNC
)spec_offtoblk
}, /* blkofftoblk */
1616 { &vnop_blockmap_desc
, (VOPFUNC
)spec_blockmap
}, /* blockmap */
1618 { &vnop_setlabel_desc
, (VOPFUNC
)devfs_setlabel
}, /* setlabel */
1620 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
1622 struct vnodeopv_desc devfs_spec_vnodeop_opv_desc
=
1623 { &devfs_spec_vnodeop_p
, devfs_spec_vnodeop_entries
};
1627 int (**devfs_devfd_vnodeop_p
)(void*);
1628 static struct vnodeopv_entry_desc devfs_devfd_vnodeop_entries
[] = {
1629 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
1630 { &vnop_lookup_desc
, (VOPFUNC
)devfs_devfd_lookup
}, /* lookup */
1631 { &vnop_open_desc
, (VOPFUNC
)nop_open
}, /* open */
1632 { &vnop_close_desc
, (VOPFUNC
)devfs_close
}, /* close */
1633 { &vnop_getattr_desc
, (VOPFUNC
)devfs_getattr
}, /* getattr */
1634 { &vnop_setattr_desc
, (VOPFUNC
)devfs_setattr
}, /* setattr */
1635 { &vnop_revoke_desc
, (VOPFUNC
)err_revoke
}, /* revoke */
1636 { &vnop_fsync_desc
, (VOPFUNC
)nop_fsync
}, /* fsync */
1637 { &vnop_readdir_desc
, (VOPFUNC
)devfs_devfd_readdir
}, /* readdir */
1638 { &vnop_inactive_desc
, (VOPFUNC
)devfs_inactive
}, /* inactive */
1639 { &vnop_reclaim_desc
, (VOPFUNC
)devfs_reclaim
}, /* reclaim */
1640 { &vnop_pathconf_desc
, (VOPFUNC
)devs_vnop_pathconf
}, /* pathconf */
1642 { &vnop_setlabel_desc
, (VOPFUNC
)devfs_setlabel
}, /* setlabel */
1644 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
1646 struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc
=
1647 { &devfs_devfd_vnodeop_p
, devfs_devfd_vnodeop_entries
};