xref: /titanic_51/usr/src/uts/common/sys/fs/hsfs_susp.h (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
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  * ISO 9660 RRIP extension filesystem specifications
24  * Copyright (c) 1991,1997-1998,2000 by Sun Microsystems, Inc.
25  * All rights reserved.
26  */
27 
28 #ifndef	_SYS_FS_HSFS_SUSP_H
29 #define	_SYS_FS_HSFS_SUSP_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #define	DEBUGGING_ALL	0
38 #define	DEBUGGING	0
39 #define	DPRINTF		if (DEBUGGING) printf
40 #define	DPRINTF_ALL	if (DEBUGGING_ALL) printf
41 
42 /*
43  * 	return values from SUA parsing
44  */
45 #define	SUA_NULL_POINTER	-1
46 #define	END_OF_SUA_PARSING	-2
47 #define	END_OF_SUA		-3
48 #define	GET_CONTINUATION	-4
49 #define	SUA_ENOMEM		-5
50 #define	SUA_EINVAL		-6
51 #define	RELOC_DIR		-7	/* actually for rrip */
52 
53 /*
54  * For dealing with implemented bits...
55  *    These here expect the fsp and a bit as an agument
56  */
57 #define	SET_IMPL_BIT(fsp, y)	((fsp->hsfs_ext_impl)  |= (0x01L) << (y))
58 #define	UNSET_IMPL_BIT(fsp, y)	((fsp->hsfs_ext_impl)  &= ~((0x01L) << (y)))
59 #define	IS_IMPL_BIT_SET(fsp, y)	((fsp->hsfs_ext_impl)  & ((0x01L) << (y)))
60 
61 #define	HAVE_SUSP		0	/* have a SUSP */
62 #define	HAVE_PROHIBITED		1	/* prohibited file/dir type in fs */
63 
64 /*
65  * For dealing with implemented bits...
66  *    These here expect just the fsp->hsfs_ext_impl
67  */
68 #define	SET_SUSP_BIT(fsp)	(SET_IMPL_BIT((fsp), HAVE_SUSP))
69 #define	UNSET_SUSP_BIT(fsp)	(UNSET_IMPL_BIT((fsp), HAVE_SUSP))
70 #define	IS_SUSP_IMPLEMENTED(fsp) (IS_IMPL_BIT_SET(fsp, 0) ? 1 : 0)
71 
72 #define	SUSP_VERSION	1
73 
74 /*
75  * SUSP signagure definitions
76  */
77 #define	SUSP_SP		"SP"
78 #define	SUSP_CE		"CE"
79 #define	SUSP_PD		"PD"
80 #define	SUSP_ER		"ER"
81 #define	SUSP_ST		"ST"
82 
83 /*
84  * 	Generic System Use Field (SUF) Macros and declarations
85  */
86 
87 #define	SUF_SIG_LEN	2			/* length of signatures */
88 #define	SUF_MIN_LEN	4			/* minimum length of a */
89 						/* 	signature field */
90 
91 #define	SUF_LEN(x)	*(SUF_len(x))		/* SUF length */
92 #define	SUF_len(x)	(&((uchar_t *)x)[2])	/* SUF length */
93 
94 #define	SUF_VER(x)	*(SUF_ver(x))		/* SUF version */
95 #define	SUF_ver(x)	(&((uchar_t *)x)[3])	/* SUF version */
96 
97 /*
98  * Extension Reference Macros
99  */
100 
101 #define	ER_ID_LEN(x)	*(ER_id_len(x))	/* Extension ref id length */
102 #define	ER_id_len(x)	(&((uchar_t *)x)[4])	/* Extension ref id length */
103 
104 
105 #define	ER_DES_LEN(x)	*(ER_des_len(x))	/* Extension ref description */
106 						/* 	length */
107 #define	ER_des_len(x)	(&((uchar_t *)x)[5])	/* Extension ref description */
108 						/* 	length */
109 
110 #define	ER_SRC_LEN(x)	*(ER_src_len(x))	/* Extension ref source */
111 						/* 	description length */
112 
113 #define	ER_src_len(x)	(&((uchar_t *)x)[6])	/* Extension ref source */
114 						/* description length */
115 
116 
117 #define	ER_EXT_VER(x)	*(ER_ext_ver(x))	/* Extension ref description */
118 						/*  length */
119 #define	ER_ext_ver(x)	(&((uchar_t *)x)[7])	/* Extension ref description */
120 						/* length */
121 
122 #define	ER_EXT_ID_LOC	8			/* location where the ER id */
123 						/* string begins */
124 
125 #define	ER_ext_id(x)	(&((uchar_t *)x)[ER_EXT_ID_LOC])
126 						/* extension id string */
127 
128 #define	ER_ext_des(x)	(&((uchar_t *)x)[ER_EXT_ID_LOC + ER_ID_LEN(x)])
129 						/* ext. description string */
130 
131 #define	ER_ext_src(x)	(&((uchar_t *)x)[ER_EXT_ID_LOC + ER_ID_LEN(x) + \
132 					ER_DES_LEN(x)])
133 						/* ext. source string */
134 
135 
136 /*
137  * Continuation Area Macros
138  */
139 #define	CE_BLK_LOC(x)	BOTH_INT(CE_blk_loc(x))	/* cont. starting block */
140 #define	CE_blk_loc(x)	(&((uchar_t *)x)[4])	/* cont. starting block */
141 
142 #define	CE_OFFSET(x)	BOTH_INT(CE_offset(x))	/* cont. offset */
143 #define	CE_offset(x)	(&((uchar_t *)x)[12])	/* cont. offset */
144 
145 #define	CE_CONT_LEN(x)	BOTH_INT(CE_cont_len(x))	/* continuation len */
146 #define	CE_cont_len(x)	(&((uchar_t *)x)[20])	/* continuation len */
147 
148 
149 /*
150  * Sharing Protocol (SP) Macros
151  */
152 #define	SP_CHK_BYTE_1(x)	*(SP_chk_byte_1(x))	/* check bytes */
153 #define	SP_chk_byte_1(x)	(&((uchar_t *)x)[4])	/* check bytes */
154 
155 #define	SP_CHK_BYTE_2(x)	*(SP_chk_byte_2(x))	/* check bytes */
156 #define	SP_chk_byte_2(x)	(&((uchar_t *)x)[5])	/* check bytes */
157 
158 #define	SUSP_CHECK_BYTE_1	(uchar_t)0xBE		/* check for 0xBE */
159 #define	SUSP_CHECK_BYTE_2	(uchar_t)0xEF		/* check for 0xEF */
160 
161 #define	CHECK_BYTES_OK(x)	((SP_CHK_BYTE_1(x) == SUSP_CHECK_BYTE_1) && \
162 				(SP_CHK_BYTE_2(x) == SUSP_CHECK_BYTE_2))
163 
164 #define	SP_SUA_OFFSET(x)	*(SP_sua_offset(x))	/* SUA bytes to skip */
165 #define	SP_sua_offset(x)	(&((uchar_t *)x)[6])	/* SUA bytes to skip */
166 
167 
168 
169 /*
170  * Forward declarations
171  */
172 
173 #ifdef _KERNEL
174 
175 extern uchar_t *share_protocol();
176 extern uchar_t *share_ext_ref();
177 extern uchar_t *share_continue();
178 extern uchar_t *share_padding();
179 extern uchar_t *share_stop();
180 
181 #endif
182 
183 /*
184  * Extension signature structure, to corrolate the handler functions
185  * with the signatures
186  */
187 struct extension_signature_struct {
188 	char	*ext_signature;		/* extension signature */
189 	uchar_t	*(*sig_handler)();	/* extension handler function */
190 };
191 
192 typedef	struct extension_signature_struct	ext_signature_t;
193 
194 
195 /*
196  * Extension name structure, to corrolate the extensions with their own
197  * 	signature tables.
198  */
199 struct extension_name_struct {
200 	char  		*extension_name;	/* ER field identifier */
201 	ushort_t	ext_version;		/* version # of extensions */
202 	ext_signature_t	*signature_table;	/* pointer to signature */
203 						/*   table for appropriate */
204 						/*   extension */
205 };
206 
207 typedef	struct extension_name_struct extension_name_t;
208 
209 /*
210  * Extern declaration for all supported extensions
211  */
212 struct	cont_info_struct	{
213 	uint_t	cont_lbn;	/* location  of cont */
214 	uint_t	cont_offset;	/* offset into cont */
215 	uint_t	cont_len;	/* len of cont */
216 };
217 
218 typedef struct cont_info_struct	cont_info_t;
219 
220 /*
221  * Structure for passing arguments to sig_handler()'s.  Since there are
222  * so many sig_handler()'s, it would be slower to pass multiple
223  * arguments to all of them. It would also ease maintainance
224  */
225 struct sig_args_struct {
226 	uchar_t			*dirp;		/* pointer to ISO dir entry */
227 	uchar_t			*name_p;	/* dir entry name */
228 	int			*name_len_p;	/* dir entry name length */
229 	short			flags;		/* misc flags */
230 	ulong_t			name_flags;		/* misc flags */
231 	uchar_t			*SUF_ptr;	/* pointer to current SUF */
232 	struct hs_direntry	*hdp;		/* directory entry  */
233 	struct hsfs		*fsp;		/* file system  */
234 	cont_info_t		*cont_info_p;	/* continuation area */
235 };
236 
237 typedef struct sig_args_struct	sig_args_t;
238 
239 
240 /*
241  * Extern declaration for all supported extensions
242  */
243 
244 #ifdef _KERNEL
245 
246 extern ext_signature_t		rrip_signature_table[];
247 extern ext_signature_t		susp_signature_table[];
248 extern extension_name_t		extension_name_table[];
249 
250 extern ext_signature_t		*susp_sp;
251 
252 extern int parse_sua(uchar_t *, int *name_len_p, int *, uchar_t *, struct
253 	hs_direntry *,	struct hsfs *,	uchar_t	*, int search_num);
254 
255 #endif	/* _KERNEL */
256 
257 #ifdef	__cplusplus
258 }
259 #endif
260 
261 #endif	/* _SYS_FS_HSFS_SUSP_H */
262