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