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