summaryrefslogtreecommitdiff
path: root/src/kernel/iso9660.h
blob: 271e5e0ab7b707f21d7d2d7127ed1b15ec9a1911 (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
93
94
95
96
/*
Copyright 2019 Benji Dial

Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby
granted, provided that the above copyright notice and this
permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
*/

#include <stdint.h>
#include <stdbool.h>

#ifndef ISO9660_H
#define ISO9660_H

enum iso_9660_vd_type {
  BOOT_RECORD = 0,
  PRIM_VOLUME = 1,
  SUPP_VOLUME = 2,
  PARTITION   = 3
};

struct iso_9660_timecode {
  uint8_t year[4];
  uint8_t month[2];
  uint8_t day[2];
  uint8_t hour[2];
  uint8_t minute[2];
  uint8_t second[2];
  uint8_t centisecond[2];
  uint8_t tzone;//0 = -12, 100 = +13
} __attribute__ ((__packed__));

struct iso_9660_directory {
  uint8_t filler[34];//TODO
} __attribute__ ((__packed__));

struct iso_9660_primary_vd {
  uint8_t type;
  uint8_t id[5];
  uint8_t version;
  uint8_t spacing;
  uint8_t system_id[32];
  uint8_t volume_id[32];
  uint64_t spacing2;
  uint32_t size;//in blocks
  uint32_t size_be;
  uint64_t spacing3[4];
  uint16_t set_size;
  uint16_t set_size_be;
  uint16_t set_index;
  uint16_t set_index_be;
  uint16_t block_size;
  uint16_t block_size_be;
  uint32_t path_table_size;
  uint32_t path_table_size_be;
  uint32_t path_table_block;
  uint32_t optional_path_table_block;
  uint32_t path_table_block_be;
  uint32_t optional_path_table_block_be;
  struct iso_9660_directory root_directory;
  uint8_t set_name[128];
  uint8_t publisher[128];
  uint8_t data_preparer[128];
  uint8_t application[128];
  uint8_t copyright_file[38];
  uint8_t abstract_file[36];
  uint8_t bibliography_file[37];
  struct iso_9660_timecode created;
  struct iso_9660_timecode modified;
  struct iso_9660_timecode expires;
  struct iso_9660_timecode effective;
  uint8_t directory_format_version;
} __attribute__ ((__packed__));

struct iso_9660_cache {
  uint16_t block_size;
  struct iso_9660_directory root_directory;
  uint32_t path_table_size;
  uint32_t path_table_sector;
  uint32_t optional_path_table_sector;
};

bool iso_9660_parse_ph(uint8_t dn, uint8_t pn, uint32_t sector, uint8_t *buffer);

#endif