GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/makefs/cd9660/iso.h Lines: 0 8 0.0 %
Date: 2017-11-07 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: iso.h,v 1.2 2016/12/17 16:22:04 krw Exp $	*/
2
/*	$NetBSD: iso.h,v 1.10 2011/09/27 01:01:44 christos Exp $	*/
3
4
/*-
5
 * Copyright (c) 1994
6
 *	The Regents of the University of California.  All rights reserved.
7
 *
8
 * This code is derived from software contributed to Berkeley
9
 * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
10
 * Support code is derived from software contributed to Berkeley
11
 * by Atsushi Murai (amurai@spec.co.jp).
12
 *
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions
15
 * are met:
16
 * 1. Redistributions of source code must retain the above copyright
17
 *    notice, this list of conditions and the following disclaimer.
18
 * 2. Redistributions in binary form must reproduce the above copyright
19
 *    notice, this list of conditions and the following disclaimer in the
20
 *    documentation and/or other materials provided with the distribution.
21
 * 3. Neither the name of the University nor the names of its contributors
22
 *    may be used to endorse or promote products derived from this software
23
 *    without specific prior written permission.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35
 * SUCH DAMAGE.
36
 *
37
 *	@(#)iso.h	8.6 (Berkeley) 5/10/95
38
 */
39
40
/*
41
 * Definitions describing ISO9660 file system structure, as well as
42
 * the functions necessary to access fields of ISO9660 file system
43
 * structures.
44
 */
45
46
#ifndef _ISOFS_CD9660_ISO_H_
47
#define _ISOFS_CD9660_ISO_H_
48
49
#define ISODCL(from, to) (to - from + 1)
50
51
struct iso_volume_descriptor {
52
	char type[ISODCL(1,1)]; /* 711 */
53
	char id[ISODCL(2,6)];
54
	char version[ISODCL(7,7)];
55
	char data[ISODCL(8,2048)];
56
};
57
58
/* volume descriptor types */
59
#define ISO_VD_PRIMARY 1
60
#define ISO_VD_SUPPLEMENTARY 2
61
#define ISO_VD_END 255
62
63
#define ISO_STANDARD_ID "CD001"
64
#define ISO_ECMA_ID     "CDW01"
65
66
#define	ISO_MAXNAMLEN	255
67
68
struct iso_primary_descriptor {
69
	char type			[ISODCL (  1,   1)]; /* 711 */
70
	char id				[ISODCL (  2,   6)];
71
	char version			[ISODCL (  7,   7)]; /* 711 */
72
	char unused1			[ISODCL (  8,   8)];
73
	char system_id			[ISODCL (  9,  40)]; /* achars */
74
	char volume_id			[ISODCL ( 41,  72)]; /* dchars */
75
	char unused2			[ISODCL ( 73,  80)];
76
	char volume_space_size		[ISODCL ( 81,  88)]; /* 733 */
77
	char unused3			[ISODCL ( 89, 120)];
78
	char volume_set_size		[ISODCL (121, 124)]; /* 723 */
79
	char volume_sequence_number	[ISODCL (125, 128)]; /* 723 */
80
	char logical_block_size		[ISODCL (129, 132)]; /* 723 */
81
	char path_table_size		[ISODCL (133, 140)]; /* 733 */
82
	char type_l_path_table		[ISODCL (141, 144)]; /* 731 */
83
	char opt_type_l_path_table	[ISODCL (145, 148)]; /* 731 */
84
	char type_m_path_table		[ISODCL (149, 152)]; /* 732 */
85
	char opt_type_m_path_table	[ISODCL (153, 156)]; /* 732 */
86
	char root_directory_record	[ISODCL (157, 190)]; /* 9.1 */
87
	char volume_set_id		[ISODCL (191, 318)]; /* dchars */
88
	char publisher_id		[ISODCL (319, 446)]; /* achars */
89
	char preparer_id		[ISODCL (447, 574)]; /* achars */
90
	char application_id		[ISODCL (575, 702)]; /* achars */
91
	char copyright_file_id		[ISODCL (703, 739)]; /* 7.5 dchars */
92
	char abstract_file_id		[ISODCL (740, 776)]; /* 7.5 dchars */
93
	char bibliographic_file_id	[ISODCL (777, 813)]; /* 7.5 dchars */
94
	char creation_date		[ISODCL (814, 830)]; /* 8.4.26.1 */
95
	char modification_date		[ISODCL (831, 847)]; /* 8.4.26.1 */
96
	char expiration_date		[ISODCL (848, 864)]; /* 8.4.26.1 */
97
	char effective_date		[ISODCL (865, 881)]; /* 8.4.26.1 */
98
	char file_structure_version	[ISODCL (882, 882)]; /* 711 */
99
	char unused4			[ISODCL (883, 883)];
100
	char application_data		[ISODCL (884, 1395)];
101
	char unused5			[ISODCL (1396, 2048)];
102
};
103
#define ISO_DEFAULT_BLOCK_SIZE		2048
104
105
struct iso_supplementary_descriptor {
106
	char type			[ISODCL (  1,	1)]; /* 711 */
107
	char id				[ISODCL (  2,	6)];
108
	char version			[ISODCL (  7,	7)]; /* 711 */
109
	char flags			[ISODCL (  8,	8)]; /* 711? */
110
	char system_id			[ISODCL (  9,  40)]; /* achars */
111
	char volume_id			[ISODCL ( 41,  72)]; /* dchars */
112
	char unused2			[ISODCL ( 73,  80)];
113
	char volume_space_size		[ISODCL ( 81,  88)]; /* 733 */
114
	char escape			[ISODCL ( 89, 120)];
115
	char volume_set_size		[ISODCL (121, 124)]; /* 723 */
116
	char volume_sequence_number	[ISODCL (125, 128)]; /* 723 */
117
	char logical_block_size		[ISODCL (129, 132)]; /* 723 */
118
	char path_table_size		[ISODCL (133, 140)]; /* 733 */
119
	char type_l_path_table		[ISODCL (141, 144)]; /* 731 */
120
	char opt_type_l_path_table	[ISODCL (145, 148)]; /* 731 */
121
	char type_m_path_table		[ISODCL (149, 152)]; /* 732 */
122
	char opt_type_m_path_table	[ISODCL (153, 156)]; /* 732 */
123
	char root_directory_record	[ISODCL (157, 190)]; /* 9.1 */
124
	char volume_set_id		[ISODCL (191, 318)]; /* dchars */
125
	char publisher_id		[ISODCL (319, 446)]; /* achars */
126
	char preparer_id		[ISODCL (447, 574)]; /* achars */
127
	char application_id		[ISODCL (575, 702)]; /* achars */
128
	char copyright_file_id		[ISODCL (703, 739)]; /* 7.5 dchars */
129
	char abstract_file_id		[ISODCL (740, 776)]; /* 7.5 dchars */
130
	char bibliographic_file_id	[ISODCL (777, 813)]; /* 7.5 dchars */
131
	char creation_date		[ISODCL (814, 830)]; /* 8.4.26.1 */
132
	char modification_date		[ISODCL (831, 847)]; /* 8.4.26.1 */
133
	char expiration_date		[ISODCL (848, 864)]; /* 8.4.26.1 */
134
	char effective_date		[ISODCL (865, 881)]; /* 8.4.26.1 */
135
	char file_structure_version	[ISODCL (882, 882)]; /* 711 */
136
	char unused4			[ISODCL (883, 883)];
137
	char application_data		[ISODCL (884, 1395)];
138
	char unused5			[ISODCL (1396, 2048)];
139
};
140
141
struct iso_directory_record {
142
	char length			[ISODCL (1, 1)]; /* 711 */
143
	char ext_attr_length		[ISODCL (2, 2)]; /* 711 */
144
	u_char extent			[ISODCL (3, 10)]; /* 733 */
145
	u_char size			[ISODCL (11, 18)]; /* 733 */
146
	char date			[ISODCL (19, 25)]; /* 7 by 711 */
147
	char flags			[ISODCL (26, 26)];
148
	char file_unit_size		[ISODCL (27, 27)]; /* 711 */
149
	char interleave			[ISODCL (28, 28)]; /* 711 */
150
	char volume_sequence_number	[ISODCL (29, 32)]; /* 723 */
151
	char name_len			[ISODCL (33, 33)]; /* 711 */
152
	char name			[1];			/* XXX */
153
};
154
/* can't take sizeof(iso_directory_record), because of possible alignment
155
   of the last entry (34 instead of 33) */
156
#define ISO_DIRECTORY_RECORD_SIZE	33
157
158
struct iso_extended_attributes {
159
	u_char owner			[ISODCL (1, 4)]; /* 723 */
160
	u_char group			[ISODCL (5, 8)]; /* 723 */
161
	u_char perm			[ISODCL (9, 10)]; /* 9.5.3 */
162
	char ctime			[ISODCL (11, 27)]; /* 8.4.26.1 */
163
	char mtime			[ISODCL (28, 44)]; /* 8.4.26.1 */
164
	char xtime			[ISODCL (45, 61)]; /* 8.4.26.1 */
165
	char ftime			[ISODCL (62, 78)]; /* 8.4.26.1 */
166
	char recfmt			[ISODCL (79, 79)]; /* 711 */
167
	char recattr			[ISODCL (80, 80)]; /* 711 */
168
	u_char reclen			[ISODCL (81, 84)]; /* 723 */
169
	char system_id			[ISODCL (85, 116)]; /* achars */
170
	char system_use			[ISODCL (117, 180)];
171
	char version			[ISODCL (181, 181)]; /* 711 */
172
	char len_esc			[ISODCL (182, 182)]; /* 711 */
173
	char reserved			[ISODCL (183, 246)];
174
	u_char len_au			[ISODCL (247, 250)]; /* 723 */
175
};
176
177
/* 7.1.1: unsigned char */
178
static __inline __unused int
179
isonum_711(const u_char *p)
180
{
181
	return *p;
182
}
183
184
/* 7.1.2: signed char */
185
static __inline __unused int
186
isonum_712(const u_char *p)
187
{
188
	return (signed char) *p;
189
}
190
191
/* 7.2.1: unsigned little-endian 16-bit value.  NOT USED IN KERNEL. */
192
static __inline int
193
isonum_721(p)
194
	u_char *p;
195
{
196
#if !defined(__STRICT_ALIGNMENT) && (BYTE_ORDER == LITTLE_ENDIAN)
197
	return *(u_int16_t *)p;
198
#else
199
	return *p|((char)p[1] << 8);
200
#endif
201
}
202
203
/* 7.2.2: unsigned big-endian 16-bit value.  NOT USED IN KERNEL. */
204
static __inline int
205
isonum_722(p)
206
	unsigned char *p;
207
{
208
#if !defined(__STRICT_ALIGNMENT) && (BYTE_ORDER == BIG_ENDIAN)
209
	return *(u_int16_t *)p;
210
#else
211
	return ((char)*p << 8)|p[1];
212
#endif
213
}
214
215
/* 7.2.3: unsigned both-endian (little, then big) 16-bit value */
216
static __inline int
217
isonum_723(u_char *p)
218
{
219
#if !defined(__STRICT_ALIGNMENT) && \
220
    ((BYTE_ORDER == LITTLE_ENDIAN) || (BYTE_ORDER == BIG_ENDIAN))
221
#if BYTE_ORDER == LITTLE_ENDIAN
222
	return *(u_int16_t *)p;
223
#else
224
	return *(u_int16_t *)(p + 2);
225
#endif
226
#else /* __STRICT_ALIGNMENT or weird byte order */
227
	return *p|(p[1] << 8);
228
#endif
229
}
230
231
/* 7.3.1: unsigned little-endian 32-bit value.  NOT USED IN KERNEL. */
232
static __inline int
233
isonum_731(p)
234
	u_char *p;
235
{
236
#if !defined(__STRICT_ALIGNMENT) && (BYTE_ORDER == LITTLE_ENDIAN)
237
	return *(u_int32_t *)p;
238
#else
239
	return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
240
#endif
241
}
242
243
/* 7.3.2: unsigned big-endian 32-bit value.  NOT USED IN KERNEL. */
244
static __inline int
245
isonum_732(p)
246
	unsigned char *p;
247
{
248
#if !defined(__STRICT_ALIGNMENT) && (BYTE_ORDER == BIG_ENDIAN)
249
	return *(u_int32_t *)p;
250
#else
251
	return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3];
252
#endif
253
}
254
255
/* 7.3.3: unsigned both-endian (little, then big) 32-bit value */
256
static __inline int
257
isonum_733(u_char *p)
258
{
259
#if !defined(__STRICT_ALIGNMENT) && \
260
    ((BYTE_ORDER == LITTLE_ENDIAN) || (BYTE_ORDER == BIG_ENDIAN))
261
#if BYTE_ORDER == LITTLE_ENDIAN
262
	return *(u_int32_t *)p;
263
#else
264
	return *(u_int32_t *)(p + 4);
265
#endif
266
#else /* __STRICT_ALIGNMENT or weird byte order */
267
	return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
268
#endif
269
}
270
271
/*
272
 * Associated files have a leading '='.
273
 */
274
#define	ASSOCCHAR	'='
275
276
#endif /* _ISOFS_CD9660_ISO_H_ */