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