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