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