aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kernel/core/kmain.c2
-rw-r--r--src/kernel/dev/pciide.c16
-rw-r--r--src/kernel/fs/iso9660.c19
-rw-r--r--src/kernel/include/fs/iso9660.h10
4 files changed, 28 insertions, 19 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index 7bdf27d..8242f99 100644
--- a/src/kernel/core/kmain.c
+++ b/src/kernel/core/kmain.c
@@ -251,7 +251,7 @@ fs_t *setup_rootfs(btree_t *cmdline, fs_t *iofs) {
fs_handle_t *root_dev = fs_open(iofs, root, FM_READ | FM_WRITE | FM_IOCTL);
if (root_dev == 0) {
dbg_printf("read-only... ");
- root_dev = fs_open(iofs, root, FM_READ | FM_WRITE | FM_IOCTL);
+ root_dev = fs_open(iofs, root, FM_READ | FM_IOCTL);
}
dbg_printf("\n");
if (root_dev == 0) PANIC("Could not open root device.");
diff --git a/src/kernel/dev/pciide.c b/src/kernel/dev/pciide.c
index 5d79470..ad7375b 100644
--- a/src/kernel/dev/pciide.c
+++ b/src/kernel/dev/pciide.c
@@ -642,7 +642,6 @@ typedef struct {
static bool ide_vfs_open(fs_node_ptr n, int mode, fs_handle_t *s);
static bool ide_vfs_stat(fs_node_ptr n, stat_t *st);
-static void ide_vfs_dispose(fs_node_ptr n);
static size_t ide_vfs_read(fs_handle_ptr f, size_t offset, size_t len, char* buf);
static size_t ide_vfs_write(fs_handle_ptr f, size_t offset, size_t len, const char* buf);
@@ -656,7 +655,7 @@ static fs_node_ops_t ide_vfs_node_ops = {
.delete = 0,
.move = 0,
.create = 0,
- .dispose = ide_vfs_dispose
+ .dispose = 0
};
static fs_handle_ops_t ide_vfs_handle_ops = {
@@ -721,10 +720,6 @@ bool ide_vfs_stat(fs_node_ptr n, stat_t *st) {
return true;
}
-void ide_vfs_dispose(fs_node_ptr n) {
- free(n);
-}
-
size_t ide_vfs_read(fs_handle_ptr f, size_t offset, size_t len, char* buf) {
ide_vfs_dev_t *d = (ide_vfs_dev_t*)f;
@@ -752,12 +747,15 @@ uint8_t err = ide_write_sectors(d->c, d->device,
int ide_vfs_ioctl(fs_handle_ptr f, int command, void* data) {
ide_vfs_dev_t *d = (ide_vfs_dev_t*)f;
+ int ret = 0;
+
if (command == IOCTL_BLOCKDEV_GET_BLOCK_SIZE)
- return d->block_size;
+ ret = d->block_size;
if (command == IOCTL_BLOCKDEV_GET_BLOCK_COUNT)
- return d->c->devices[d->device].size;
+ ret = d->c->devices[d->device].size;
- return 0;
+ dbg_printf("ioctl (0x%p) %d -> %d\n", f, command, ret);
+ return ret;
}
void ide_vfs_close(fs_handle_ptr f) {
diff --git a/src/kernel/fs/iso9660.c b/src/kernel/fs/iso9660.c
index b17a975..d8c103f 100644
--- a/src/kernel/fs/iso9660.c
+++ b/src/kernel/fs/iso9660.c
@@ -9,8 +9,9 @@ static fs_driver_ops_t iso9660_driver_ops = {
};
void register_iso9660_driver() {
- //ASSERT(sizeof(iso9660_vdt_entry_t) == 2048);
- //ASSERT(sizeof(iso9660_dr_t) == 34);
+ ASSERT(sizeof(iso9660_dr_date_t) == 7);
+ ASSERT(sizeof(iso9660_dr_t) == 34);
+ ASSERT(sizeof(iso9660_vdt_entry_t) == 2048);
register_fs_driver("iso9660", &iso9660_driver_ops);
}
@@ -22,11 +23,21 @@ void register_iso9660_driver() {
static bool iso9660_make(fs_handle_t *source, const char* opts, fs_t *t) {
stat_t st;
if (!file_stat(source, &st)) return false;
- if ((st.type & FT_BLOCKDEV) != 0) return false;
+ if ((st.type & FT_BLOCKDEV) == 0) return false;
- uint32_t block_size = file_ioctl(source, IOCTL_BLOCKDEV_GET_BLOCK_SIZE, 0);
+ int block_size = file_ioctl(source, IOCTL_BLOCKDEV_GET_BLOCK_SIZE, 0);
if (block_size != 2048) return false;
+ // Look up primary volume descriptor entry
+ iso9660_vdt_entry_t ent;
+ int ent_sect = 0x10;
+ while (true) {
+ if (file_read(source, ent_sect * 2048, 2048, ent.buf) != 2048) return false;
+ if (ent.boot.type == ISO9660_VDT_PRIMARY) break; // ok got it!
+ if (ent.boot.type == ISO9660_VDT_TERMINATOR) return false; // doesn't exist ?
+ ent_sect++;
+ }
+
return false; // TODO
}
diff --git a/src/kernel/include/fs/iso9660.h b/src/kernel/include/fs/iso9660.h
index fcaec1a..292b4dd 100644
--- a/src/kernel/include/fs/iso9660.h
+++ b/src/kernel/include/fs/iso9660.h
@@ -37,8 +37,8 @@ typedef struct { // Directory record
uint8_t interleave_gap_size;
uint16_lsb_msb_t vol_seq_num;
uint8_t name_len;
- char name[2]; // we want sizeof(iso9660_dr_t) == 34
-} iso9660_dr_t;
+ char name[1]; // we want sizeof(iso9660_dr_t) == 34
+} __attribute__((packed)) iso9660_dr_t;
typedef struct { // Boot record
uint8_t type;
@@ -47,7 +47,7 @@ typedef struct { // Boot record
char sys_ident[32];
char boot_ident[32];
char reserved[1977];
-} iso9660_bootrecord_t;
+} __attribute__((packed)) iso9660_bootrecord_t;
typedef struct { // Primary volume descriptor
uint8_t type;
@@ -72,13 +72,13 @@ typedef struct { // Primary volume descriptor
iso9660_dr_t root_directory;
// more fields (not interesting...)
-} iso9660_pvd_t;
+} __attribute__((packed)) iso9660_pvd_t;
typedef struct {
uint8_t type;
char ident[5];
uint8_t version; // always 1
-} iso9660_vdt_terminator_t; // volume descriptor table terminator
+} __attribute__((packed)) iso9660_vdt_terminator_t; // volume descriptor table terminator
typedef union {
iso9660_bootrecord_t boot;