aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/include/fs/iso9660.h
blob: 292b4dd5e41da6359c18f9ab3c36e2e853370e23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once

#include <vfs.h>

#define ISO9660_VDT_BOOT	0
#define ISO9660_VDT_PRIMARY 1
#define ISO9660_VDT_SUPPLEMENTARY 2
#define ISO9660_VDT_PARTITION 3
#define ISO9660_VDT_TERMINATOR 255

typedef struct {
	uint32_t lsb, msb;
} uint32_lsb_msb_t;

typedef struct {
	uint16_t lsb, msb;
} uint16_lsb_msb_t;

typedef struct {
	uint8_t years_since_1990;
	uint8_t month;
	uint8_t day;
	uint8_t hour;
	uint8_t minute;
	uint8_t second;
	uint8_t gmt_offset;
} iso9660_dr_date_t;

typedef struct {		// Directory record
	uint8_t len;		// length of the record
	uint8_t ear_len;	// length of extended attribute record
	uint32_lsb_msb_t lba_loc;	// location of extent
	uint32_lsb_msb_t size;		// size of extent
	iso9660_dr_date_t date;
	uint8_t flags;
	uint8_t interleave_unit_size;
	uint8_t interleave_gap_size;
	uint16_lsb_msb_t vol_seq_num;
	uint8_t name_len;
	char name[1];		// we want sizeof(iso9660_dr_t) == 34
} __attribute__((packed)) iso9660_dr_t;

typedef struct {		// Boot record
	uint8_t type;
	char ident[5];
	uint8_t version;	// always 1
	char sys_ident[32];
	char boot_ident[32];
	char reserved[1977];
} __attribute__((packed)) iso9660_bootrecord_t;

typedef struct {		// Primary volume descriptor
	uint8_t type;
	char ident[5];
	uint8_t version;	// always 1

	uint8_t unused0;

	char sys_ident[32];
	char vol_ident[32];

	uint8_t unused1[8];

	uint32_lsb_msb_t volume_size;
	uint8_t unused2[32];

	uint16_lsb_msb_t volume_set_size, volume_seq_number;
	uint16_lsb_msb_t block_size;
	uint32_lsb_msb_t path_table_size;
	uint32_t lpt_loc, olpt_loc, mpt_loc, ompt_loc;	// location of path tables

	iso9660_dr_t root_directory;

	// more fields (not interesting...)
} __attribute__((packed)) iso9660_pvd_t;

typedef struct {
	uint8_t type;
	char ident[5];
	uint8_t version;	// always 1
} __attribute__((packed)) iso9660_vdt_terminator_t;		// volume descriptor table terminator

typedef union {
	iso9660_bootrecord_t boot;
	iso9660_pvd_t prim;
	iso9660_vdt_terminator_t term;
	char buf[2048];
} iso9660_vdt_entry_t;

void register_iso9660_driver();

/* vim: set ts=4 sw=4 tw=0 noet :*/