xref: /original-bsd/sys/isofs/cd9660/iso.h (revision 898c7514)
1 /*-
2  * Copyright (c) 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley
6  * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
7  * Support code is derived from software contributed to Berkeley
8  * by Atsushi Murai (amurai@spec.co.jp).
9  *
10  * %sccs.include.redist.c%
11  *
12  *	@(#)iso.h	8.6 (Berkeley) 05/10/95
13  */
14 
15 #define ISODCL(from, to) (to - from + 1)
16 
17 struct iso_volume_descriptor {
18 	char type[ISODCL(1,1)]; /* 711 */
19 	char id[ISODCL(2,6)];
20 	char version[ISODCL(7,7)];
21 	char data[ISODCL(8,2048)];
22 };
23 
24 /* volume descriptor types */
25 #define ISO_VD_PRIMARY 1
26 #define ISO_VD_END 255
27 
28 #define ISO_STANDARD_ID "CD001"
29 #define ISO_ECMA_ID     "CDW01"
30 
31 struct iso_primary_descriptor {
32 	char type			[ISODCL (  1,   1)]; /* 711 */
33 	char id				[ISODCL (  2,   6)];
34 	char version			[ISODCL (  7,   7)]; /* 711 */
35 	char unused1			[ISODCL (  8,   8)];
36 	char system_id			[ISODCL (  9,  40)]; /* achars */
37 	char volume_id			[ISODCL ( 41,  72)]; /* dchars */
38 	char unused2			[ISODCL ( 73,  80)];
39 	char volume_space_size		[ISODCL ( 81,  88)]; /* 733 */
40 	char unused3			[ISODCL ( 89, 120)];
41 	char volume_set_size		[ISODCL (121, 124)]; /* 723 */
42 	char volume_sequence_number	[ISODCL (125, 128)]; /* 723 */
43 	char logical_block_size		[ISODCL (129, 132)]; /* 723 */
44 	char path_table_size		[ISODCL (133, 140)]; /* 733 */
45 	char type_l_path_table		[ISODCL (141, 144)]; /* 731 */
46 	char opt_type_l_path_table	[ISODCL (145, 148)]; /* 731 */
47 	char type_m_path_table		[ISODCL (149, 152)]; /* 732 */
48 	char opt_type_m_path_table	[ISODCL (153, 156)]; /* 732 */
49 	char root_directory_record	[ISODCL (157, 190)]; /* 9.1 */
50 	char volume_set_id		[ISODCL (191, 318)]; /* dchars */
51 	char publisher_id		[ISODCL (319, 446)]; /* achars */
52 	char preparer_id		[ISODCL (447, 574)]; /* achars */
53 	char application_id		[ISODCL (575, 702)]; /* achars */
54 	char copyright_file_id		[ISODCL (703, 739)]; /* 7.5 dchars */
55 	char abstract_file_id		[ISODCL (740, 776)]; /* 7.5 dchars */
56 	char bibliographic_file_id	[ISODCL (777, 813)]; /* 7.5 dchars */
57 	char creation_date		[ISODCL (814, 830)]; /* 8.4.26.1 */
58 	char modification_date		[ISODCL (831, 847)]; /* 8.4.26.1 */
59 	char expiration_date		[ISODCL (848, 864)]; /* 8.4.26.1 */
60 	char effective_date		[ISODCL (865, 881)]; /* 8.4.26.1 */
61 	char file_structure_version	[ISODCL (882, 882)]; /* 711 */
62 	char unused4			[ISODCL (883, 883)];
63 	char application_data		[ISODCL (884, 1395)];
64 	char unused5			[ISODCL (1396, 2048)];
65 };
66 #define ISO_DEFAULT_BLOCK_SIZE		2048
67 
68 struct iso_directory_record {
69 	char length			[ISODCL (1, 1)]; /* 711 */
70 	char ext_attr_length		[ISODCL (2, 2)]; /* 711 */
71 	u_char extent			[ISODCL (3, 10)]; /* 733 */
72 	u_char size			[ISODCL (11, 18)]; /* 733 */
73 	char date			[ISODCL (19, 25)]; /* 7 by 711 */
74 	char flags			[ISODCL (26, 26)];
75 	char file_unit_size		[ISODCL (27, 27)]; /* 711 */
76 	char interleave			[ISODCL (28, 28)]; /* 711 */
77 	char volume_sequence_number	[ISODCL (29, 32)]; /* 723 */
78 	char name_len			[ISODCL (33, 33)]; /* 711 */
79 	char name			[1];			/* XXX */
80 };
81 /* can't take sizeof(iso_directory_record), because of possible alignment
82    of the last entry (34 instead of 33) */
83 #define ISO_DIRECTORY_RECORD_SIZE	33
84 
85 struct iso_extended_attributes {
86 	u_char owner			[ISODCL (1, 4)]; /* 723 */
87 	u_char group			[ISODCL (5, 8)]; /* 723 */
88 	u_char perm			[ISODCL (9, 10)]; /* 9.5.3 */
89 	char ctime			[ISODCL (11, 27)]; /* 8.4.26.1 */
90 	char mtime			[ISODCL (28, 44)]; /* 8.4.26.1 */
91 	char xtime			[ISODCL (45, 61)]; /* 8.4.26.1 */
92 	char ftime			[ISODCL (62, 78)]; /* 8.4.26.1 */
93 	char recfmt			[ISODCL (79, 79)]; /* 711 */
94 	char recattr			[ISODCL (80, 80)]; /* 711 */
95 	u_char reclen			[ISODCL (81, 84)]; /* 723 */
96 	char system_id			[ISODCL (85, 116)]; /* achars */
97 	char system_use			[ISODCL (117, 180)];
98 	char version			[ISODCL (181, 181)]; /* 711 */
99 	char len_esc			[ISODCL (182, 182)]; /* 711 */
100 	char reserved			[ISODCL (183, 246)];
101 	u_char len_au			[ISODCL (247, 250)]; /* 723 */
102 };
103 
104 /* CD-ROM Format type */
105 enum ISO_FTYPE  { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_ECMA };
106 
107 #ifndef	ISOFSMNT_ROOT
108 #define	ISOFSMNT_ROOT	0
109 #endif
110 
111 struct iso_mnt {
112 	int im_flags;
113 
114 	struct mount *im_mountp;
115 	dev_t im_dev;
116 	struct vnode *im_devvp;
117 
118 	int logical_block_size;
119 	int im_bshift;
120 	int im_bmask;
121 
122 	int volume_space_size;
123 	struct netexport im_export;
124 
125 	char root[ISODCL (157, 190)];
126 	int root_extent;
127 	int root_size;
128 	enum ISO_FTYPE  iso_ftype;
129 
130 	int rr_skip;
131 	int rr_skip0;
132 };
133 
134 #define VFSTOISOFS(mp)	((struct iso_mnt *)((mp)->mnt_data))
135 
136 #define blkoff(imp, loc)	((loc) & (imp)->im_bmask)
137 #define lblktosize(imp, blk)	((blk) << (imp)->im_bshift)
138 #define lblkno(imp, loc)	((loc) >> (imp)->im_bshift)
139 #define blksize(imp, ip, lbn)	((imp)->logical_block_size)
140 
141 int cd9660_mount __P((struct mount *,
142 	    char *, caddr_t, struct nameidata *, struct proc *));
143 int cd9660_start __P((struct mount *, int, struct proc *));
144 int cd9660_unmount __P((struct mount *, int, struct proc *));
145 int cd9660_root __P((struct mount *, struct vnode **));
146 int cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
147 int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *));
148 int cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *));
149 int cd9660_vget __P((struct mount *, ino_t, struct vnode **));
150 int cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
151 	    struct vnode **, int *, struct ucred **));
152 int cd9660_vptofh __P((struct vnode *, struct fid *));
153 int cd9660_init __P((struct vfsconf *));
154 #define cd9660_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \
155                                     size_t, struct proc *)))eopnotsupp)
156 
157 int cd9660_mountroot __P((void));
158 
159 extern int (**cd9660_vnodeop_p)();
160 extern int (**cd9660_specop_p)();
161 #ifdef FIFO
162 extern int (**cd9660_fifoop_p)();
163 #endif
164 
165 static __inline int
166 isonum_711(p)
167 	u_char *p;
168 {
169 	return *p;
170 }
171 
172 static __inline int
173 isonum_712(p)
174 	char *p;
175 {
176 	return *p;
177 }
178 
179 #ifndef UNALIGNED_ACCESS
180 
181 static __inline int
182 isonum_723(p)
183 	u_char *p;
184 {
185 	return *p|(p[1] << 8);
186 }
187 
188 static __inline int
189 isonum_733(p)
190 	u_char *p;
191 {
192 	return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
193 }
194 
195 #else /* UNALIGNED_ACCESS */
196 
197 #if BYTE_ORDER == LITTLE_ENDIAN
198 
199 static __inline int
200 isonum_723(p)
201 	u_char *p
202 {
203 	return *(u_int16t *)p;
204 }
205 
206 static __inline int
207 isonum_733(p)
208 	u_char *p;
209 {
210 	return *(u_int32t *)p;
211 }
212 
213 #endif
214 
215 #if BYTE_ORDER == BIG_ENDIAN
216 
217 static __inline int
218 isonum_723(p)
219 	u_char *p
220 {
221 	return *(u_int16t *)(p + 2);
222 }
223 
224 static __inline int
225 isonum_733(p)
226 	u_char *p;
227 {
228 	return *(u_int32t *)(p + 4);
229 }
230 
231 #endif
232 
233 #endif /* UNALIGNED_ACCESS */
234 
235 int isofncmp __P((u_char *, int, u_char *, int));
236 void isofntrans __P((u_char *, int, u_char *, u_short *, int, int));
237 ino_t isodirino __P((struct iso_directory_record *, struct iso_mnt *));
238 
239 /*
240  * Associated files have a leading '='.
241  */
242 #define	ASSOCCHAR	'='
243