summaryrefslogtreecommitdiff
path: root/src/kernel/drive.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-01 22:35:26 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-01 22:35:26 -0500
commit1d69a46f5d9823bbf2e6211ca367b409d2d5f7a7 (patch)
treea49a5498080551270a827a205cde49477d4d89ff /src/kernel/drive.c
parent6f1b50a4cc6c232ee505a543f006abb1c6cd33cf (diff)
downloadportland-os-1d69a46f5d9823bbf2e6211ca367b409d2d5f7a7.tar.gz
minimal file writing, shutdown keybinding (Win+Shift+Q)
Diffstat (limited to 'src/kernel/drive.c')
-rw-r--r--src/kernel/drive.c28
1 files changed, 12 insertions, 16 deletions
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;