xref: /titanic_41/usr/src/uts/common/sys/fs/pc_node.h (revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1989, 1992, 1997-1998, 2000, 2003 Sun Microsystems, Inc.
24  * All rights reserved.  Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FS_PC_NODE_H
28 #define	_SYS_FS_PC_NODE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <vm/page.h>
37 #include <sys/buf.h>
38 #include <sys/vnode.h>
39 
40 /*
41  * This overlays the fid structure (see vfs.h)
42  *
43  * 10 bytes max.
44  */
45 struct pc_fid {
46 	ushort_t	pcfid_len;
47 	uint32_t	pcfid_block;	/* dblock containing directory entry */
48 	uint16_t	pcfid_offset;	/* offset within block of entry */
49 	uint16_t	pcfid_ctime;	/* creation time of entry (~= i_gen) */
50 };
51 
52 struct pcnode {
53 	struct pcnode	*pc_forw;	/* active list ptrs, must be first */
54 	struct pcnode	*pc_back;
55 	int pc_flags;			/* see below */
56 	struct vnode	*pc_vn;		/* vnode for pcnode */
57 	uint_t pc_size;			/* size of file */
58 	pc_cluster32_t	pc_scluster;	/* starting cluster of file */
59 	daddr_t pc_eblkno;		/* disk blkno for entry */
60 	int pc_eoffset;			/* offset in disk block of entry */
61 	struct pcdir pc_entry;		/* directory entry of file */
62 	pc_cluster32_t	pc_lcluster;	/* last cluster visited */
63 	daddr_t		pc_lindex;	/* index of last cluster visited */
64 };
65 
66 /*
67  * flags
68  */
69 #define	PC_MOD		0x01		/* file data has been modified */
70 #define	PC_CHG		0x02		/* node data has been changed */
71 #define	PC_INVAL	0x04		/* node is invalid */
72 #define	PC_EXTERNAL	0x08		/* vnode ref is held externally */
73 #define	PC_ACC		0x10		/* file data has been accessed */
74 #define	PC_RELEHOLD	0x80		/* node is being released */
75 
76 #define	PCTOV(PCP)	((PCP)->pc_vn)
77 #define	VTOPC(VP)	((struct pcnode *)((VP)->v_data))
78 
79 /*
80  * Make a unique integer for a file
81  */
82 #define	pc_makenodeid(BN, OFF, ATTR, SCLUSTER, ENTPS) \
83 	(ino_t)((ATTR) & PCA_DIR ? \
84 		(uint32_t)(-(SCLUSTER) - 1) : \
85 		((BN) * (ENTPS)) + ((OFF) / sizeof (struct pcdir)))
86 
87 #define	NPCHASH 1
88 
89 #if NPCHASH == 1
90 #define	PCFHASH(FSP, BN, O)	0
91 #define	PCDHASH(FSP, SC)	0
92 #else
93 #define	PCFHASH(FSP, BN, O)	(((unsigned)FSP + BN + O) % NPCHASH)
94 #define	PCDHASH(FSP, SC)	(((unsigned)FSP + SC) % NPCHASH)
95 #endif
96 
97 struct pchead {
98 	struct pcnode *pch_forw;
99 	struct pcnode *pch_back;
100 };
101 
102 /*
103  * pcnode file and directory operations vectors
104  */
105 extern struct vnodeops *pcfs_fvnodeops;
106 extern struct vnodeops *pcfs_dvnodeops;
107 extern const struct fs_operation_def pcfs_fvnodeops_template[];
108 extern const struct fs_operation_def pcfs_dvnodeops_template[];
109 extern struct pchead pcfhead[];
110 extern struct pchead pcdhead[];
111 
112 /*
113  * pcnode routines
114  */
115 extern void pc_init(void);
116 extern struct pcnode *pc_getnode(struct pcfs *, daddr_t, int, struct pcdir *);
117 extern void pc_rele(struct pcnode *);
118 extern void pc_mark_mod(struct pcnode *);
119 extern void pc_mark_acc(struct pcnode *);
120 extern int pc_nodesync(struct pcnode *);
121 extern int pc_nodeupdate(struct pcnode *);
122 extern int pc_bmap(struct pcnode *, daddr_t, daddr_t *, uint_t *);
123 
124 extern int pc_balloc(struct pcnode *, daddr_t, int, daddr_t *);
125 extern int pc_bfree(struct pcnode *, pc_cluster32_t);
126 extern int pc_verify(struct pcfs *);
127 extern void pc_diskchanged(struct pcfs *);
128 extern void pc_mark_irrecov(struct pcfs *);
129 
130 extern int pc_dirlook(struct pcnode *, char *, struct pcnode **);
131 extern int pc_direnter(struct pcnode *, char *, struct vattr *,
132 	struct pcnode **);
133 extern int pc_dirremove(struct pcnode *, char *, struct vnode *, enum vtype);
134 extern int pc_rename(struct pcnode *, struct pcnode *, char *, char *);
135 extern int pc_blkatoff(struct pcnode *, offset_t, struct buf **,
136 	struct pcdir **);
137 extern int pc_truncate(struct pcnode *, uint_t);
138 extern int pc_fileclsize(struct pcfs *, pc_cluster32_t);
139 extern int pcfs_putapage(struct vnode *, page_t *, u_offset_t *, size_t *, int,
140 	struct cred *);
141 extern void pc_badfs(struct pcfs *);
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif	/* _SYS_FS_PC_NODE_H */
148