-
Notifications
You must be signed in to change notification settings - Fork 3
/
iso9660.c
71 lines (58 loc) · 1.55 KB
/
iso9660.c
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
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <kernel.h>
#include "DiskFile.h"
#include "iso9660.h"
DiskFile g_files[256];
inline void *sector(unsigned int sectornum)
{
static u8 *cdimg = (void *) 0x10000000;
return &cdimg[sectornum * 2048];
}
DiskFile * iso9660_enumfiles()
{
const PrimaryVolumeDescriptor *pvd = sector(16);
const DirectoryRecord *rootrecord = &pvd->root_directory_record;
assert(rootrecord->record_len == sizeof(DirectoryRecord) + rootrecord->id_len);
const DirectoryRecord *entry = sector(rootrecord->data_sector);
int i=0;
do {
DiskFile *fp = &g_files[i++];
strncpy(fp->filename, entry->id, entry->id_len);
fp->data = sector(entry->data_sector);
fp->length = entry->data_len;
DPRINT(1, "CD file: %s at 0x%x (%u bytes)",
fp->filename, fp->data, fp->length);
entry = NEXT_DIR_ENTRY(entry);
} while (entry->record_len > 0);
g_files[i].filename[0] = 0;
g_files[i].data = NULL;
g_files[i].length = 0;
return g_files;
}
DiskFile *
iso9660_fopen_r(const char *filename)
{
DiskFile *files = iso9660_enumfiles();
int i=0;
for ( ; files[i].data; ++i)
{
DiskFile *df = &files[i];
if (strncmp(df->filename, filename, sizeof(df->filename)) == 0)
{
return df;
}
else
{
DPRINT(0, "skipping file '%s'", df->filename);
}
}
return NULL;
}
DiskFile *
iso9660_fopen_w(const char *filename)
{
return NULL;
}