From 1d69a46f5d9823bbf2e6211ca367b409d2d5f7a7 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 1 Mar 2021 22:35:26 -0500 Subject: minimal file writing, shutdown keybinding (Win+Shift+Q) --- src/kernel/drive.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/kernel/drive.c') diff --git a/src/kernel/drive.c b/src/kernel/drive.c index 2ae050f..8dc0e68 100644 --- a/src/kernel/drive.c +++ b/src/kernel/drive.c @@ -1,6 +1,7 @@ #include "drive.h" #include "panic.h" #include "fat.h" +#include "log.h" uint8_t n_drives; struct drive drives[256]; @@ -14,21 +15,9 @@ static file_id_t unknown_get_file(const struct drive *d, const char *path) { return 0; } -static void unknown_free_file(const struct drive *d, file_id_t fid) { - PANIC("Free file called on unknown file system."); -} - -static void unknown_load_sector(const struct drive *d, file_id_t fid, uint32_t sector, void *at) { - PANIC("Load sector called on unknown file system."); -} - -static uint32_t unknown_get_file_length(const struct drive *d, file_id_t fid) { - PANIC("Get file length called on unknown file system."); -} - __attribute__ ((const)) static uint32_t unknown_get_free_sectors(const struct drive *d) { - return -1; + return 0; } __attribute__ ((const)) @@ -41,15 +30,22 @@ static uint32_t unknown_n_dir_entries(const struct drive *d, const char *path) { return 0; } +static void unknown_no_call(const struct drive *d) { + logf(LOG_ERROR, "file-level operation called on drive %u (%s), which is an unknown file system", d - drives + 1, d->fs_type); +} + static inline void determine_fs(struct drive *d) { if (try_fat_init_drive(d)) return; d->fs_type = "Unknown"; d->get_file = &unknown_get_file; - d->free_file = &unknown_free_file; - d->load_sector = &unknown_load_sector; - d->get_file_length = &unknown_get_file_length; + d->free_file = &unknown_no_call; + d->load_sector = &unknown_no_call; + d->save_sector = &unknown_no_call; + d->is_writable = &unknown_no_call; + d->get_file_length = &unknown_no_call; + d->set_file_length = &unknown_no_call; d->enumerate_dir = &unknown_enumerate_dir; d->n_dir_entries = &unknown_n_dir_entries; d->get_free_sectors = &unknown_get_free_sectors; -- cgit v1.2.3