xref: /netbsd-src/sys/fs/filecorefs/filecore_node.h (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /*	$NetBSD: filecore_node.h,v 1.4 2005/12/03 17:34:43 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 1994 The Regents of the University of California.
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. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *	filecore_node.h		1.1	1998/6/26
32  */
33 
34 /*-
35  * Copyright (c) 1998 Andrew McMurry
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  * 1. Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  * 2. Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in the
44  *    documentation and/or other materials provided with the distribution.
45  * 3. All advertising materials mentioning features or use of this software
46  *    must display the following acknowledgement:
47  *	This product includes software developed by the University of
48  *	California, Berkeley and its contributors.
49  * 4. Neither the name of the University nor the names of its contributors
50  *    may be used to endorse or promote products derived from this software
51  *    without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63  * SUCH DAMAGE.
64  *
65  *	filecore_node.h		1.1	1998/6/26
66  */
67 
68 #if !defined(_KERNEL)
69 #error not supposed to be exposed to userland.
70 #endif
71 
72 #include <miscfs/genfs/genfs_node.h>
73 
74 /*
75  * In a future format, directories may be more than 2Gb in length,
76  * however, in practice this seems unlikely. So, we define
77  * the type doff_t as a long to keep down the cost of doing
78  * lookup on a 32-bit machine. If you are porting to a 64-bit
79  * architecture, you should make doff_t the same as off_t.
80  */
81 #define doff_t	long
82 
83 struct filecore_node {
84 	struct	genfs_node i_gnode;
85 	LIST_ENTRY(filecore_node) i_hash;
86 	struct	vnode *i_vnode;	/* vnode associated with this inode */
87 	struct	vnode *i_devvp;	/* vnode for block I/O */
88 	u_long	i_flag;		/* see below */
89 	dev_t	i_dev;		/* device where inode resides */
90 	ino_t	i_number;	/* the identity of the inode */
91 	daddr_t	i_block;	/* the disc address of the file */
92 	ino_t	i_parent;	/* the ino of the file's parent */
93 
94 	struct	filecore_mnt *i_mnt;	/* filesystem associated with this inode */
95 	struct	lockf *i_lockf;	/* head of byte-level lock list */
96         int	i_diroff;	/* offset in dir, where we found last entry */
97 
98 	struct	filecore_direntry i_dirent; /* directory entry */
99 };
100 
101 #define	i_forw		i_chain[0]
102 #define	i_back		i_chain[1]
103 #define i_size		i_dirent.len
104 
105 /* flags */
106 #define	IN_ACCESS	0x0020		/* inode access time to be updated */
107 
108 #define VTOI(vp) ((struct filecore_node *)(vp)->v_data)
109 #define ITOV(ip) ((ip)->i_vnode)
110 
111 #define filecore_staleinode(ip) ((ip)->i_dirent.name[0]==0)
112 
113 /*
114  * Prototypes for Filecore vnode operations
115  */
116 int	filecore_lookup		__P((void *));
117 #define	filecore_open		genfs_nullop
118 #define	filecore_close		genfs_nullop
119 int	filecore_access		__P((void *));
120 int	filecore_getattr	__P((void *));
121 int	filecore_read		__P((void *));
122 #define	filecore_poll		genfs_poll
123 #define	filecore_mmap		genfs_mmap
124 #define	filecore_seek		genfs_seek
125 int	filecore_readdir	__P((void *));
126 int	filecore_readlink	__P((void *));
127 #define	filecore_abortop	genfs_abortop
128 int	filecore_inactive	__P((void *));
129 int	filecore_reclaim	__P((void *));
130 int	filecore_link		__P((void *));
131 int	filecore_symlink	__P((void *));
132 int	filecore_bmap		__P((void *));
133 int	filecore_strategy	__P((void *));
134 int	filecore_print		__P((void *));
135 int	filecore_pathconf	__P((void *));
136 int	filecore_blkatoff	__P((void *));
137 
138 struct	vnode *filecore_ihashget __P((dev_t, ino_t));
139 void	filecore_ihashins __P((struct filecore_node *));
140 void	filecore_ihashrem __P((struct filecore_node *));
141 
142 mode_t	filecore_mode	__P((struct filecore_node *));
143 struct timespec	filecore_time	__P((struct filecore_node *));
144 ino_t	filecore_getparent	__P((struct filecore_node *));
145 int	filecore_fn2unix	__P((char *, char *, u_int16_t *));
146 int	filecore_fncmp		__P((const char *, const char *, u_short));
147 int	filecore_dbread		__P((struct filecore_node *, struct buf **));
148