Home | History | Annotate | Line # | Download | only in specfs
specdev.h revision 1.34
      1 /*	$NetBSD: specdev.h,v 1.34 2008/01/24 17:32:55 ad Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2008 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the NetBSD
     18  *	Foundation, Inc. and its contributors.
     19  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20  *    contributors may be used to endorse or promote products derived
     21  *    from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33  * POSSIBILITY OF SUCH DAMAGE.
     34  */
     35 
     36 /*
     37  * Copyright (c) 1990, 1993
     38  *	The Regents of the University of California.  All rights reserved.
     39  *
     40  * Redistribution and use in source and binary forms, with or without
     41  * modification, are permitted provided that the following conditions
     42  * are met:
     43  * 1. Redistributions of source code must retain the above copyright
     44  *    notice, this list of conditions and the following disclaimer.
     45  * 2. Redistributions in binary form must reproduce the above copyright
     46  *    notice, this list of conditions and the following disclaimer in the
     47  *    documentation and/or other materials provided with the distribution.
     48  * 3. Neither the name of the University nor the names of its contributors
     49  *    may be used to endorse or promote products derived from this software
     50  *    without specific prior written permission.
     51  *
     52  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     53  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     56  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  * SUCH DAMAGE.
     63  *
     64  *	@(#)specdev.h	8.6 (Berkeley) 5/21/95
     65  */
     66 
     67 #ifndef _MISCFS_SPECFS_SPECDEV_H_
     68 #define _MISCFS_SPECFS_SPECDEV_H_
     69 
     70 #include <sys/mutex.h>
     71 #include <sys/vnode.h>
     72 
     73 typedef struct specnode {
     74 	vnode_t		*sn_next;
     75 	struct specdev	*sn_dev;
     76 	u_int		sn_opencnt;
     77 	dev_t		sn_rdev;
     78 	bool		sn_gone;
     79 } specnode_t;
     80 
     81 typedef struct specdev {
     82 	struct mount	*sd_mountpoint;
     83 	struct lockf	*sd_lockf;
     84 	vnode_t		*sd_bdevvp;
     85 	u_int		sd_opencnt;
     86 	u_int		sd_refcnt;
     87 	dev_t		sd_rdev;
     88 } specdev_t;
     89 
     90 /*
     91  * Exported shorthand
     92  */
     93 #define v_specnext	v_specnode->sn_next
     94 #define v_rdev		v_specnode->sn_rdev
     95 #define v_speclockf	v_specnode->sn_dev->sd_lockf
     96 #define v_specmountpoint v_specnode->sn_dev->sd_mountpoint
     97 
     98 /*
     99  * Special device management
    100  */
    101 #define	SPECHSZ	64
    102 #if	((SPECHSZ&(SPECHSZ-1)) == 0)
    103 #define	SPECHASH(rdev)	(((rdev>>5)+(rdev))&(SPECHSZ-1))
    104 #else
    105 #define	SPECHASH(rdev)	(((unsigned)((rdev>>5)+(rdev)))%SPECHSZ)
    106 #endif
    107 
    108 extern vnode_t	*specfs_hash[SPECHSZ];
    109 extern kmutex_t	specfs_lock;
    110 
    111 void	spec_node_init(vnode_t *, dev_t);
    112 void	spec_node_destroy(vnode_t *);
    113 void	spec_node_revoke(vnode_t *);
    114 
    115 /*
    116  * Prototypes for special file operations on vnodes.
    117  */
    118 extern	int (**spec_vnodeop_p)(void *);
    119 struct	nameidata;
    120 struct	componentname;
    121 struct	flock;
    122 struct	buf;
    123 struct	uio;
    124 
    125 int	spec_lookup(void *);
    126 #define	spec_create	genfs_badop
    127 #define	spec_mknod	genfs_badop
    128 int	spec_open(void *);
    129 int	spec_close(void *);
    130 #define	spec_access	genfs_ebadf
    131 #define	spec_getattr	genfs_ebadf
    132 #define	spec_setattr	genfs_ebadf
    133 int	spec_read(void *);
    134 int	spec_write(void *);
    135 #define	spec_lease_check genfs_nullop
    136 #define spec_fcntl	genfs_fcntl
    137 int	spec_ioctl(void *);
    138 int	spec_poll(void *);
    139 int	spec_kqfilter(void *);
    140 #define spec_revoke	genfs_revoke
    141 int	spec_mmap(void *);
    142 int	spec_fsync(void *);
    143 #define	spec_seek	genfs_nullop		/* XXX should query device */
    144 #define	spec_remove	genfs_badop
    145 #define	spec_link	genfs_badop
    146 #define	spec_rename	genfs_badop
    147 #define	spec_mkdir	genfs_badop
    148 #define	spec_rmdir	genfs_badop
    149 #define	spec_symlink	genfs_badop
    150 #define	spec_readdir	genfs_badop
    151 #define	spec_readlink	genfs_badop
    152 #define	spec_abortop	genfs_badop
    153 #define	spec_reclaim	genfs_nullop
    154 int	spec_inactive(void *);
    155 #define	spec_lock	genfs_nolock
    156 #define	spec_unlock	genfs_nounlock
    157 int	spec_bmap(void *);
    158 int	spec_strategy(void *);
    159 int	spec_print(void *);
    160 #define	spec_islocked	genfs_noislocked
    161 int	spec_pathconf(void *);
    162 int	spec_advlock(void *);
    163 #define	spec_bwrite	vn_bwrite
    164 #define	spec_getpages	genfs_getpages
    165 #define	spec_putpages	genfs_putpages
    166 
    167 #endif /* _MISCFS_SPECFS_SPECDEV_H_ */
    168