xref: /original-bsd/sys/isofs/cd9660/iso.h (revision 27393bdf)
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.5 (Berkeley) 03/30/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 	char im_fsmnt[50];
124 	struct netexport im_export;
125 
126 	char root[ISODCL (157, 190)];
127 	int root_extent;
128 	int root_size;
129 	enum ISO_FTYPE  iso_ftype;
130 
131 	int rr_skip;
132 	int rr_skip0;
133 };
134 
135 #define VFSTOISOFS(mp)	((struct iso_mnt *)((mp)->mnt_data))
136 
137 #define blkoff(imp, loc)	((loc) & (imp)->im_bmask)
138 #define lblktosize(imp, blk)	((blk) << (imp)->im_bshift)
139 #define lblkno(imp, loc)	((loc) >> (imp)->im_bshift)
140 #define blksize(imp, ip, lbn)	((imp)->logical_block_size)
141 
142 int cd9660_mount __P((struct mount *,
143 	    char *, caddr_t, struct nameidata *, struct proc *));
144 int cd9660_start __P((struct mount *, int, struct proc *));
145 int cd9660_unmount __P((struct mount *, int, struct proc *));
146 int cd9660_root __P((struct mount *, struct vnode **));
147 int cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
148 int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *));
149 int cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *));
150 int cd9660_vget __P((struct mount *, ino_t, struct vnode **));
151 int cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
152 	    struct vnode **, int *, struct ucred **));
153 int cd9660_vptofh __P((struct vnode *, struct fid *));
154 int cd9660_init __P((struct vfsconf *));
155 #define cd9660_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \
156                                     size_t, struct proc *)))eopnotsupp)
157 
158 int cd9660_mountroot __P((void));
159 
160 extern int (**cd9660_vnodeop_p)();
161 extern int (**cd9660_specop_p)();
162 #ifdef FIFO
163 extern int (**cd9660_fifoop_p)();
164 #endif
165 
166 static __inline int
167 isonum_711(p)
168 	u_char *p;
169 {
170 	return *p;
171 }
172 
173 static __inline int
174 isonum_712(p)
175 	char *p;
176 {
177 	return *p;
178 }
179 
180 #ifndef UNALIGNED_ACCESS
181 
182 static __inline int
183 isonum_723(p)
184 	u_char *p;
185 {
186 	return *p|(p[1] << 8);
187 }
188 
189 static __inline int
190 isonum_733(p)
191 	u_char *p;
192 {
193 	return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
194 }
195 
196 #else /* UNALIGNED_ACCESS */
197 
198 #if BYTE_ORDER == LITTLE_ENDIAN
199 
200 static __inline int
201 isonum_723(p)
202 	u_char *p
203 {
204 	return *(u_int16t *)p;
205 }
206 
207 static __inline int
208 isonum_733(p)
209 	u_char *p;
210 {
211 	return *(u_int32t *)p;
212 }
213 
214 #endif
215 
216 #if BYTE_ORDER == BIG_ENDIAN
217 
218 static __inline int
219 isonum_723(p)
220 	u_char *p
221 {
222 	return *(u_int16t *)(p + 2);
223 }
224 
225 static __inline int
226 isonum_733(p)
227 	u_char *p;
228 {
229 	return *(u_int32t *)(p + 4);
230 }
231 
232 #endif
233 
234 #endif /* UNALIGNED_ACCESS */
235 
236 int isofncmp __P((u_char *, int, u_char *, int));
237 void isofntrans __P((u_char *, int, u_char *, u_short *, int, int));
238 ino_t isodirino __P((struct iso_directory_record *, struct iso_mnt *));
239 
240 /*
241  * Associated files have a leading '='.
242  */
243 #define	ASSOCCHAR	'='
244