summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-04 14:57:31 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-04 14:57:31 -0500
commit86af7f631080bc4b45846bd7f382c4cedcbec2b4 (patch)
treed92510da292edeaacdebb2b84fc5fe61e1b9159f /src
parent922470255bef5d09e2c12cc2b6597e629f3b2581 (diff)
downloadportland-os-86af7f631080bc4b45846bd7f382c4cedcbec2b4.tar.gz
making fs drivers ignore already open files during kernel setup and when opening init for the first time
Diffstat (limited to 'src')
-rw-r--r--src/kernel/drive.c2
-rw-r--r--src/kernel/drive.h2
-rw-r--r--src/kernel/fat.c2
-rw-r--r--src/kernel/main.c4
4 files changed, 9 insertions, 1 deletions
diff --git a/src/kernel/drive.c b/src/kernel/drive.c
index 8dc0e68..bc1c67d 100644
--- a/src/kernel/drive.c
+++ b/src/kernel/drive.c
@@ -6,6 +6,8 @@
uint8_t n_drives;
struct drive drives[256];
+bool ignore_already_open = false;
+
void init_drives() {
n_drives = 0;
}
diff --git a/src/kernel/drive.h b/src/kernel/drive.h
index 93811e8..d09365d 100644
--- a/src/kernel/drive.h
+++ b/src/kernel/drive.h
@@ -49,4 +49,6 @@ extern struct drive drives[MAX_DRIVES];
void init_drives();
void commit_drive(struct drive data);
+extern bool ignore_already_open;
+
#endif \ No newline at end of file
diff --git a/src/kernel/fat.c b/src/kernel/fat.c
index e328f61..b342267 100644
--- a/src/kernel/fat.c
+++ b/src/kernel/fat.c
@@ -238,7 +238,7 @@ static file_id_t fat_get_file(const struct drive *d, const char *path) {
return 0;
}
- if (cur_dir->extra_attrib & FEA_OPEN_EXCLUSIVE) {
+ if (!ignore_already_open && (cur_dir->extra_attrib & FEA_OPEN_EXCLUSIVE)) {
d->done(d);
return 0;//maybe have a special return value for this?
}
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 36b5fc1..9699029 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -38,6 +38,8 @@ void main() {
init_ide();
//other drive drivers
+ ignore_already_open = true;
+
init_log();
init_settings();
@@ -94,6 +96,8 @@ void main() {
if (!try_elf_run(drives, "bin/init", "", 0))
PANIC("Failed to load init program.");
+ ignore_already_open = false;
+
logf(LOG_INFO, "Switching to init task.");
_start_user_mode();