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