xref: /plan9-contrib/sys/src/9/pcboot/iso9660.h (revision 25210b069a6ed8c047fa67220cf1dff32812f121)
1 /*
2  * ISO 9660 CD format
3  */
4 
5 #define	VOLDESC	16	/* sector number */
6 
7 /*
8  * L means little-endian, M means big-endian, and LM means little-endian
9  * then again big-endian.
10  */
11 typedef uchar		Byte2L[2];
12 typedef uchar		Byte2M[2];
13 typedef uchar		Byte4LM[4];
14 typedef uchar		Byte4L[4];
15 typedef uchar		Byte4M[4];
16 typedef uchar		Byte8LM[8];
17 typedef union Drec	Drec;
18 typedef union Voldesc	Voldesc;
19 
20 enum {
21 	BootIso		= 0,
22 	PrimaryIso	= 1,
23 	SupplementaryIso = 2,
24 	PartitionIso	= 3,
25 	TerminatorIso	= 255,
26 };
27 
28 enum {
29 	Cdsec	= 2048,
30 	Maxname = 256,
31 };
32 
33 union Voldesc {			/* volume descriptor */
34 	uchar	byte[Cdsec];
35 	union {			/* for CD001, the ECMA standard */
36 		struct {
37 			uchar	type;
38 			uchar	stdid[5];
39 			uchar	version;
40 			uchar	unused;
41 			uchar	sysid[32];
42 			uchar	bootid[32];
43 			uchar	data[1977];
44 		} boot;
45 		struct {
46 			uchar	type;
47 			uchar	stdid[5];
48 			uchar	version;
49 			uchar	flags;
50 			uchar	sysid[32];
51 			uchar	volid[32];
52 			Byte8LM	partloc;
53 			Byte8LM	size;
54 			uchar	escapes[32];
55 			Byte4LM	vsetsize;
56 			Byte4LM	vseqno;
57 			Byte4LM	blksize;
58 			Byte8LM	ptabsize;
59 			Byte4L	lptable;
60 			Byte4L	optlptable;
61 			Byte4M	mptable;
62 			Byte4M	optmptable;
63 			uchar	rootdir[34];
64 			uchar	volsetid[128];
65 			uchar	pubid[128];
66 			uchar	prepid[128];
67 			uchar	appid[128];
68 			uchar	copyright[37];
69 			uchar	abstract[37];
70 			uchar	bibliography[37];
71 			uchar	cdate[17];
72 			uchar	mdate[17];
73 			uchar	expdate[17];
74 			uchar	effdate[17];
75 			uchar	fsversion;
76 			uchar	unused3[1];
77 			uchar	appuse[512];
78 			uchar	unused4[653];
79 		} desc;
80 	} z;
81 	union {			/* for CDROM, the `High Sierra' standard */
82 		struct {
83 			Byte8LM	number;
84 			uchar	type;
85 			uchar	stdid[5];
86 			uchar	version;
87 			uchar	flags;
88 			uchar	sysid[32];
89 			uchar	volid[32];
90 			Byte8LM	partloc;
91 			Byte8LM	size;
92 			uchar	escapes[32];
93 			Byte4LM	vsetsize;
94 			Byte4LM	vseqno;
95 			Byte4LM	blksize;
96 			uchar	quux[40];
97 			uchar	rootdir[34];
98 			uchar	volsetid[128];
99 			uchar	pubid[128];
100 			uchar	prepid[128];
101 			uchar	appid[128];
102 			uchar	copyright[32];
103 			uchar	abstract[32];
104 			uchar	cdate[16];
105 			uchar	mdate[16];
106 			uchar	expdate[16];
107 			uchar	effdate[16];
108 			uchar	fsversion;
109 		} desc;
110 	} r;
111 };
112 
113 union Drec {
114 	struct {
115 		uchar	reclen;
116 		uchar	attrlen;
117 		Byte8LM	addr;
118 		Byte8LM	size;
119 		uchar	date[6];
120 		uchar	tzone;		/* flags in high sierra */
121 		uchar	flags;		/* ? in high sierra */
122 		uchar	unitsize;	/* ? in high sierra */
123 		uchar	gapsize;	/* ? in high sierra */
124 		Byte4LM	vseqno;		/* ? in high sierra */
125 		uchar	namelen;
126 		uchar	name[1];
127 	};
128 	struct {
129 		uchar	r_pad[24];
130 		uchar	r_flags;
131 	};
132 };
133 
134 struct Isofile {
135 	short	fmt;		/* 'z' if iso, 'r' if high sierra */
136 	short	blksize;
137 	vlong	offset;		/* true offset when reading directory */
138 	long	odelta;		/* true size of directory just read */
139 	vlong	doffset;	/* plan9 offset when reading directory */
140 	Drec	d;
141 };
142