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