xref: /illumos-gate/usr/src/uts/common/sys/fs/hsfs_rrip.h (revision d10b6702)
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  */
24 /*
25  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #ifndef	_SYS_FS_HSFS_RRIP_H
30 #define	_SYS_FS_HSFS_RRIP_H
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Mount options specific to HSFS.
40  * This is not a good place for them; we should probably have a file
41  * named hsfs_mount.h for such stuff.
42  */
43 #define	HSFSMNT_NORRIP		0x1	/* -nrr option found		 */
44 #define	HSFSMNT_NOTRAILDOT	0x2	/* ignore trailing '.'		 */
45 #define	HSFSMNT_NOMAPLCASE	0x4	/* do not map filenames to lcase */
46 #define	HSFSMNT_NOTRAILSPACE	0x8	/* no trailing space in iso 9660 */
47 #define	HSFSMNT_NOVERSION	0x10	/* no version info in iso 9660 */
48 #define	HSFSMNT_NOJOLIET	0x20	/* ignore Joliet even if present */
49 #define	HSFSMNT_JOLIETLONG	0x40	/* do not truncate Joliet filenames */
50 #define	HSFSMNT_NOVERS2		0x80	/* ignore ISO-9660:1999		 */
51 #define	HSFSMNT_INODE		0x1000	/* May use ext_lbn as inode #, */
52 					/* FS is from a recent mkisofs */
53 
54 /*
55  * XXX: The following flag was used in the past to instruct the kernel to
56  *	ignore Rock Ridge extensions on a CD. Unfortunately, this was
57  *	implemented as part of the generic mount flags, a bad idea.
58  *	This flag should not be used anymore. The HSFSMNT_NORRIP
59  *	flag should be used in its place. The hsfs_mount code currently
60  *	understands this flag, but this functionality should go
61  *	away in the future.
62  */
63 #define	MS_NO_RRIP		0x800000  /* if set, don't use Rock Ridge */
64 
65 
66 #define	MIN(a, b)   ((a) < (b) ? (a) : (b))
67 
68 /*
69  * Make sure we have this first
70  */
71 
72 #define	RRIP_VERSION		1
73 #define	RRIP_SUF_VERSION	1
74 #define	RRIP_EXT_VERSION	1
75 
76 #define	RRIP_BIT	1	/* loc. in extension_name_table in susp.c */
77 
78 #define	IS_RRIP_IMPLEMENTED(fsp) (IS_IMPL_BIT_SET(fsp, RRIP_BIT) ? 1 : 0)
79 
80 
81 
82 /*
83  * RRIP signature macros
84  */
85 #define	RRIP_CL		"CL"
86 #define	RRIP_NM		"NM"
87 #define	RRIP_PL		"PL"
88 #define	RRIP_PN		"PN"
89 #define	RRIP_PX		"PX"
90 #define	RRIP_RE		"RE"
91 #define	RRIP_RR		"RR"
92 #define	RRIP_SL		"SL"
93 #define	RRIP_TF		"TF"
94 
95 /*
96  * RRIP ER extension fields
97  */
98 #define	RRIP_ER_EXT_ID		"RRIP_1991A"
99 
100 #define	RRIP_ER_EXT_DES		"THE ROCK RIDGE INTERCHANGE PROTOCOL PROVIDES \
101 SUPPORT FOR POSIX FILE SYSTEM SEMANTICS."
102 
103 #define	RRIP_ER_EXT_SRC		"PLEASE CONTACT DISC PUBLISHER FOR \
104 SPECIFICATION SOURCE.  SEE PUBLISHER IDENTIFIER IN PRIMARY VOLUME DESCRIPTOR \
105 FOR CONTACT INFORMATION."
106 
107 /*
108  * "TF" time macros
109  */
110 #define	RRIP_TF_FLAGS(x)	*(RRIP_tf_flags(x))
111 #define	RRIP_tf_flags(x)	(&((uchar_t *)(x))[4])
112 
113 #define	RRIP_TIME_START_BP	5
114 
115 #define	RRIP_TF_TIME_LENGTH(x)	(IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
116 					RRIP_TF_LONG_BIT) ? \
117 					ISO_DATE_LEN : ISO_SHORT_DATE_LEN)
118 
119 /*
120  * Time location bits
121  */
122 #define	RRIP_TF_CREATION_BIT	0x01
123 #define	RRIP_TF_MODIFY_BIT	0x02
124 #define	RRIP_TF_ACCESS_BIT	0x04
125 #define	RRIP_TF_ATTRIBUTES_BIT	0x08
126 #define	RRIP_TF_BACKUP_BIT	0x10
127 #define	RRIP_TF_EXPIRATION_BIT	0x20
128 #define	RRIP_TF_EFFECTIVE_BIT	0x40
129 #define	RRIP_TF_LONG_BIT	0x80
130 
131 
132 
133 #define	RRIP_tf_creation(x)	(&((uchar_t *)x)[RRIP_TIME_START_BP])
134 #define	RRIP_tf_modify(x)	(&((uchar_t *)x)[RRIP_TIME_START_BP + \
135 			(RRIP_TF_TIME_LENGTH(x) * \
136 				(IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
137 				RRIP_TF_CREATION_BIT)))])
138 
139 #define	RRIP_tf_access(x)	(&((uchar_t *)x)[RRIP_TIME_START_BP + \
140 			(RRIP_TF_TIME_LENGTH(x) * \
141 			(IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
142 					RRIP_TF_CREATION_BIT) + \
143 			IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
144 					RRIP_TF_MODIFY_BIT)))])
145 
146 #define	RRIP_tf_attributes(x)	(&((uchar_t *)x)[RRIP_TIME_START_BP + \
147 			(RRIP_TF_TIME_LENGTH(x) * \
148 				(IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
149 						RRIP_TF_CREATION_BIT) + \
150 				IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
151 						RRIP_TF_MODIFY_BIT) + \
152 				IS_TIME_BIT_SET(RRIP_TF_FLAGS(x), \
153 						RRIP_TF_ACCESS_BIT)))])
154 
155 
156 
157 /*
158  * Check if TF Bits are set.
159  *
160  * Note : IS_TIME_BIT_SET(x, y)  must be kept returning 1 and 0.
161  * 	see RRIP_tf_*(x) Macros
162  */
163 #define	IS_TIME_BIT_SET(x, y)	(((x) & (y))  ? 1 : 0)
164 #define	SET_TIME_BIT(x, y)	((x) |= (y))
165 
166 
167 /*
168  * "PX" Posix attibutes
169  */
170 #define	RRIP_mode(x)		(&((uchar_t *)x)[4])
171 #define	RRIP_MODE(x)		(mode_t)BOTH_INT(RRIP_mode(x))
172 
173 #define	RRIP_nlink(x)		(&((uchar_t *)x)[12])
174 #define	RRIP_NLINK(x)		(short)BOTH_INT(RRIP_nlink(x))
175 
176 #define	RRIP_uid(x)		(&((uchar_t *)x)[20])
177 #define	RRIP_UID(x)		(uid_t)BOTH_INT(RRIP_uid(x))
178 
179 #define	RRIP_gid(x)		(&((uchar_t *)x)[28])
180 #define	RRIP_GID(x)		(gid_t)BOTH_INT(RRIP_gid(x))
181 
182 #define	RRIP_ino(x)		(&((uchar_t *)x)[36])
183 #define	RRIP_INO(x)		(uint32_t)BOTH_INT(RRIP_ino(x))
184 
185 #define	RRIP_PX_OLD_SIZE	36
186 #define	RRIP_PX_SIZE		44
187 
188 /*
189  * "PN" Posix major/minor numbers
190  */
191 
192 #define	RRIP_major(x)		(&((uchar_t *)x)[4])
193 #define	RRIP_MAJOR(x)		BOTH_INT(RRIP_major(x))
194 
195 #define	RRIP_minor(x)		(&((uchar_t *)x)[12])
196 #define	RRIP_MINOR(x)		BOTH_INT(RRIP_minor(x))
197 
198 
199 /*
200  *  "NM" alternate name and "SL" symbolic link macros...
201  */
202 
203 #define	SYM_LINK_LEN(x)		(strlen(x) + 1)
204 #define	RRIP_NAME_LEN_BASE	5
205 #define	RRIP_NAME_LEN(x)	(SUF_LEN(x) - RRIP_NAME_LEN_BASE)
206 
207 #define	RRIP_NAME_FLAGS(x)	(((uchar_t *)x)[4])
208 
209 /*
210  * These are for the flag bits in the NM and SL and must remain <= 8 bits
211  */
212 #define	RRIP_NAME_CONTINUE	0x01
213 #define	RRIP_NAME_CURRENT	0x02
214 #define	RRIP_NAME_PARENT	0x04
215 #define	RRIP_NAME_ROOT		0x08
216 #define	RRIP_NAME_VOLROOT	0x10
217 #define	RRIP_NAME_HOST		0x20
218 
219 
220 /*
221  * These are unique to use in the > 8 bits of sig_args.name_flags
222  * They are > 8 so that we can share bits from above.
223  * This can grow to 32 bits.
224  */
225 #define	RRIP_NAME_CHANGE	0x40
226 #define	RRIP_SYM_LINK_COMPLETE	0x80	/* set if sym link already read */
227 					/* from SUA (no longer than a short) */
228 
229 /*
230  * Bit handling....
231  */
232 #define	SET_NAME_BIT(x, y)	((x) |= (y))
233 #define	UNSET_NAME_BIT(x, y)	((x) &= ~(y))
234 #define	IS_NAME_BIT_SET(x, y)	((x) & (y))
235 #define	NAME_HAS_CHANGED(flag)	\
236 			(IS_NAME_BIT_SET(flag, RRIP_NAME_CHANGE) ? 1 : 0)
237 
238 #define	RRIP_name(x)		(&((uchar_t *)x)[5])
239 #define	RRIP_NAME(x)		RRIP_name(x)
240 
241 /*
242  * This is the maximum filename length that we support
243  */
244 #define	RRIP_FILE_NAMELEN	255
245 
246 
247 /*
248  * SL Symbolic link macros (in addition to common name flag macos
249  */
250 /* these two macros are from the SL SUF pointer */
251 #define	RRIP_sl_comp(x)		(&((uchar_t *)x)[5])
252 #define	RRIP_SL_COMP(x)		RRIP_sl_comp(x)
253 #define	RRIP_SL_FLAGS(x)	(((uchar_t *)x)[4])
254 
255 
256 /* these macros are from the component pointer within the SL SUF */
257 #define	RRIP_comp(x)		(&((uchar_t *)x)[2])
258 #define	RRIP_COMP(x)		RRIP_comp(x)
259 #define	RRIP_COMP_FLAGS(x)	(((uchar_t *)x)[0])
260 #define	RRIP_COMP_LEN(x)	(RRIP_COMP_NAME_LEN(x) + 2)
261 #define	RRIP_COMP_NAME_LEN(x)	(((uchar_t *)x)[1])
262 
263 
264 /*
265  * Directory hierarchy macros
266  */
267 
268 /*
269  * Macros for checking relocation bits in flags member of dlist
270  * structure defined in iso_impl.h
271  */
272 #define	IS_RELOC_BIT_SET(x, y)	(((x) & (y))  ? 1 : 0)
273 #define	SET_RELOC_BIT(x, y)	((x) |= (y))
274 
275 #define	CHILD_LINK		0x01
276 #define	PARENT_LINK		0x02
277 #define	RELOCATED_DIR		0x04
278 
279 #define	RRIP_child_lbn(x)	(&((uchar_t *)x)[4])
280 #define	RRIP_CHILD_LBN(x)	(uint_t)BOTH_INT(RRIP_child_lbn(x))
281 
282 #define	RRIP_parent_lbn(x)	(&((uchar_t *)x)[4])
283 #define	RRIP_PARENT_LBN(x)	(uint_t)BOTH_INT(RRIP_parent_lbn(x))
284 
285 
286 #ifdef _KERNEL
287 
288 /*
289  * Forward declarations
290  */
291 extern uchar_t *rrip_name(sig_args_t *);
292 extern uchar_t *rrip_file_attr(sig_args_t *);
293 extern uchar_t *rrip_dev_nodes(sig_args_t *);
294 extern uchar_t *rrip_file_time(sig_args_t *);
295 extern uchar_t *rrip_sym_link(sig_args_t *);
296 extern uchar_t *rrip_parent_link(sig_args_t *);
297 extern uchar_t *rrip_child_link(sig_args_t *);
298 extern uchar_t *rrip_reloc_dir(sig_args_t *);
299 extern uchar_t *rrip_rock_ridge(sig_args_t *);
300 extern void hs_check_root_dirent(struct vnode *vp, struct hs_direntry *hdp);
301 extern int rrip_namecopy(char *from, char *to, char *tmp_name,
302 				uchar_t *dirp, uint_t last_offset,
303 				struct hsfs *fsp, struct hs_direntry *hdp);
304 #endif	/* _KERNEL */
305 
306 #ifdef	__cplusplus
307 }
308 #endif
309 
310 #endif	/* _SYS_FS_HSFS_RRIP_H */
311