xref: /illumos-gate/usr/src/uts/common/sys/fs/hsfs_rrip.h (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
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 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Mount options specific to HSFS.
38  * This is not a good place for them; we should probably have a file
39  * named hsfs_mount.h for such stuff.
40  */
41 #define	HSFSMNT_NORRIP		0x1	/* -nrr option found		 */
42 #define	HSFSMNT_NOTRAILDOT	0x2	/* ignore trailing '.'		 */
43 #define	HSFSMNT_NOMAPLCASE	0x4	/* do not map filenames to lcase */
44 #define	HSFSMNT_NOTRAILSPACE	0x8	/* no trailing space in iso 9660 */
45 #define	HSFSMNT_NOVERSION	0x10	/* no version info in iso 9660 */
46 #define	HSFSMNT_NOJOLIET	0x20	/* ignore Joliet even if present */
47 #define	HSFSMNT_JOLIETLONG	0x40	/* do not truncate Joliet filenames */
48 #define	HSFSMNT_NOVERS2		0x80	/* ignore ISO-9660:1999		 */
49 #define	HSFSMNT_INODE		0x1000	/* May use ext_lbn as inode #, */
50 					/* FS is from a recent mkisofs */
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 #define	RRIP_ino(x)		(&((uchar_t *)x)[36])
181 #define	RRIP_INO(x)		(uint32_t)BOTH_INT(RRIP_ino(x))
182 
183 #define	RRIP_PX_OLD_SIZE	36
184 #define	RRIP_PX_SIZE		44
185 
186 /*
187  * "PN" Posix major/minor numbers
188  */
189 
190 #define	RRIP_major(x)		(&((uchar_t *)x)[4])
191 #define	RRIP_MAJOR(x)		BOTH_INT(RRIP_major(x))
192 
193 #define	RRIP_minor(x)		(&((uchar_t *)x)[12])
194 #define	RRIP_MINOR(x)		BOTH_INT(RRIP_minor(x))
195 
196 
197 /*
198  *  "NM" alternate name and "SL" symbolic link macros...
199  */
200 
201 #define	SYM_LINK_LEN(x)		(strlen(x) + 1)
202 #define	RRIP_NAME_LEN_BASE	5
203 #define	RRIP_NAME_LEN(x)	(SUF_LEN(x) - RRIP_NAME_LEN_BASE)
204 
205 #define	RRIP_NAME_FLAGS(x)	(((uchar_t *)x)[4])
206 
207 /*
208  * These are for the flag bits in the NM and SL and must remain <= 8 bits
209  */
210 #define	RRIP_NAME_CONTINUE	0x01
211 #define	RRIP_NAME_CURRENT	0x02
212 #define	RRIP_NAME_PARENT	0x04
213 #define	RRIP_NAME_ROOT		0x08
214 #define	RRIP_NAME_VOLROOT	0x10
215 #define	RRIP_NAME_HOST		0x20
216 
217 
218 /*
219  * These are unique to use in the > 8 bits of sig_args.name_flags
220  * They are > 8 so that we can share bits from above.
221  * This can grow to 32 bits.
222  */
223 #define	RRIP_NAME_CHANGE	0x40
224 #define	RRIP_SYM_LINK_COMPLETE	0x80	/* set if sym link already read */
225 					/* from SUA (no longer than a short) */
226 
227 /*
228  * Bit handling....
229  */
230 #define	SET_NAME_BIT(x, y)	((x) |= (y))
231 #define	UNSET_NAME_BIT(x, y)	((x) &= ~(y))
232 #define	IS_NAME_BIT_SET(x, y)	((x) & (y))
233 #define	NAME_HAS_CHANGED(flag)	\
234 			(IS_NAME_BIT_SET(flag, RRIP_NAME_CHANGE) ? 1 : 0)
235 
236 #define	RRIP_name(x)		(&((uchar_t *)x)[5])
237 #define	RRIP_NAME(x)		RRIP_name(x)
238 
239 /*
240  * This is the maximum filename length that we support
241  */
242 #define	RRIP_FILE_NAMELEN	255
243 
244 
245 /*
246  * SL Symbolic link macros (in addition to common name flag macos
247  */
248 /* these two macros are from the SL SUF pointer */
249 #define	RRIP_sl_comp(x)		(&((uchar_t *)x)[5])
250 #define	RRIP_SL_COMP(x)		RRIP_sl_comp(x)
251 #define	RRIP_SL_FLAGS(x)	(((uchar_t *)x)[4])
252 
253 
254 /* these macros are from the component pointer within the SL SUF */
255 #define	RRIP_comp(x)		(&((uchar_t *)x)[2])
256 #define	RRIP_COMP(x)		RRIP_comp(x)
257 #define	RRIP_COMP_FLAGS(x)	(((uchar_t *)x)[0])
258 #define	RRIP_COMP_LEN(x)	(RRIP_COMP_NAME_LEN(x) + 2)
259 #define	RRIP_COMP_NAME_LEN(x)	(((uchar_t *)x)[1])
260 
261 
262 /*
263  * Directory hierarchy macros
264  */
265 
266 /*
267  * Macros for checking relocation bits in flags member of dlist
268  * structure defined in iso_impl.h
269  */
270 #define	IS_RELOC_BIT_SET(x, y)	(((x) & (y))  ? 1 : 0)
271 #define	SET_RELOC_BIT(x, y)	((x) |= (y))
272 
273 #define	CHILD_LINK		0x01
274 #define	PARENT_LINK		0x02
275 #define	RELOCATED_DIR		0x04
276 
277 #define	RRIP_child_lbn(x)	(&((uchar_t *)x)[4])
278 #define	RRIP_CHILD_LBN(x)	(uint_t)BOTH_INT(RRIP_child_lbn(x))
279 
280 #define	RRIP_parent_lbn(x)	(&((uchar_t *)x)[4])
281 #define	RRIP_PARENT_LBN(x)	(uint_t)BOTH_INT(RRIP_parent_lbn(x))
282 
283 
284 #ifdef _KERNEL
285 
286 /*
287  * Forward declarations
288  */
289 extern uchar_t *rrip_name(sig_args_t *);
290 extern uchar_t *rrip_file_attr(sig_args_t *);
291 extern uchar_t *rrip_dev_nodes(sig_args_t *);
292 extern uchar_t *rrip_file_time(sig_args_t *);
293 extern uchar_t *rrip_sym_link(sig_args_t *);
294 extern uchar_t *rrip_parent_link(sig_args_t *);
295 extern uchar_t *rrip_child_link(sig_args_t *);
296 extern uchar_t *rrip_reloc_dir(sig_args_t *);
297 extern uchar_t *rrip_rock_ridge(sig_args_t *);
298 extern void hs_check_root_dirent(struct vnode *vp, struct hs_direntry *hdp);
299 extern int rrip_namecopy(char *from, char *to, char *tmp_name,
300 				uchar_t *dirp, uint_t last_offset,
301 				struct hsfs *fsp, struct hs_direntry *hdp);
302 #endif	/* _KERNEL */
303 
304 #ifdef	__cplusplus
305 }
306 #endif
307 
308 #endif	/* _SYS_FS_HSFS_RRIP_H */
309