From de1ddb452b1306c7fb8484d864fe7a0d62e7951b Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 08:25:42 +0300 Subject: [PATCH 01/11] We need to create the necessary folders in the ramdisk. --- Rakefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Rakefile b/Rakefile index 3d633ac8..2ec22eb5 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,10 @@ end desc 'Creates the initial ramdisk image where the programs and their data is stored' task :create_ramdisk_image do sh "cd servers/block/initial_ramdisk && #{RAKE_COMMAND} create_ramdisk_image" + + sh 'mmd -o u:/config' + sh 'mmd u:/config/servers' + sh 'mmd u:/config/servers/boot' end desc 'Compiles and installs chaos' From d505b5e8e41fdec21735ff1b7f3cb49738b82b9e Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 08:26:02 +0300 Subject: [PATCH 02/11] Let's attempt to shuffle these around to see if it makes any kind of difference. --- menu.lst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu.lst b/menu.lst index 18a233ca..06033419 100644 --- a/menu.lst +++ b/menu.lst @@ -7,7 +7,7 @@ module /servers/console.gz module /servers/keyboard.gz module /servers/vga.gz module /servers/log.gz -module /servers/virtual_file_system.gz -module /servers/fat.gz module /servers/initial_ramdisk.gz +module /servers/fat.gz +module /servers/virtual_file_system.gz module /servers/boot.gz From 81c1227c105802d19708c2e3f17f496e01e3318e Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 08:26:14 +0300 Subject: [PATCH 03/11] Added more logging, to try and nail down this issue. --- servers/file_system/virtual_file_system/virtual_file_system.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/servers/file_system/virtual_file_system/virtual_file_system.c b/servers/file_system/virtual_file_system/virtual_file_system.c index 8ad6fd77..840e421f 100644 --- a/servers/file_system/virtual_file_system/virtual_file_system.c +++ b/servers/file_system/virtual_file_system/virtual_file_system.c @@ -234,6 +234,7 @@ static void vfs_file_get_info(file_verbose_directory_entry_type *directory_entry if (volume == mounted_volumes || volume == (unsigned int) -1) { + log_print_formatted(&log_structure, LOG_URGENCY_WARNING, "Failed to found matching volume for %s", directory_entry->path_name); directory_entry->success = FALSE; return; } @@ -306,6 +307,7 @@ static void vfs_file_get_info(file_verbose_directory_entry_type *directory_entry // Did the file not exist? if (input_index == mounted_volumes) { + log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "Failed to find %s in meta-root filesystem", directory_entry->path_name); directory_entry->success = FALSE; return; } From 1d5521a68383473469e76ef278bdbbbc5454596f Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 22:11:48 +0300 Subject: [PATCH 04/11] Whitespace fixes. --- servers/system/log/log.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/servers/system/log/log.c b/servers/system/log/log.c index d3729fc8..d07230e9 100644 --- a/servers/system/log/log.c +++ b/servers/system/log/log.c @@ -2,7 +2,7 @@ // from the kernel. // Authors: Per Lundberg // Henrik Hallin - +// // © Copyright 2000 chaos development // © Copyright 2007 chaos development // © Copyright 2015 chaos development @@ -119,8 +119,7 @@ static void handle_connection(void *argument) message_parameter.message_class = IPC_CLASS_NONE; message_parameter.length = data_size; - if (ipc_receive(ipc_structure.input_mailbox_id, &message_parameter, - &data_size) != IPC_RETURN_SUCCESS) + if (ipc_receive(ipc_structure.input_mailbox_id, &message_parameter, &data_size) != IPC_RETURN_SUCCESS) { continue; } @@ -131,8 +130,7 @@ static void handle_connection(void *argument) { ipc_log_print_type *ipc_log_print = (ipc_log_print_type *) data; - log_add(&console_structure_server, " " PACKAGE_NAME " version " PACKAGE_VERSION " server console.", - ipc_log_print); + log_add(&console_structure_server, " " PACKAGE_NAME " version " PACKAGE_VERSION " server console.", ipc_log_print); break; } @@ -143,8 +141,7 @@ static void handle_connection(void *argument) static return_type handle_server_logging(void) { // Open a new console for the log. - if (console_init(&console_structure_server, &empty_tag, IPC_CONSOLE_CONNECTION_CLASS_CLIENT) != - CONSOLE_RETURN_SUCCESS) + if (console_init(&console_structure_server, &empty_tag, IPC_CONSOLE_CONNECTION_CLASS_CLIENT) != CONSOLE_RETURN_SUCCESS) { return -1; } @@ -155,8 +152,7 @@ static return_type handle_server_logging(void) return -1; } - if (console_open(&console_structure_server, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) != - CONSOLE_RETURN_SUCCESS) + if (console_open(&console_structure_server, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) != CONSOLE_RETURN_SUCCESS) { return -1; } @@ -200,14 +196,12 @@ static void handle_kernel_logging(void *argument UNUSED) system_thread_name_set("Kernel log handler"); // Open a new console for the log. - if (console_init(&console_structure_kernel, &empty_tag, IPC_CONSOLE_CONNECTION_CLASS_CLIENT) != - CONSOLE_RETURN_SUCCESS) + if (console_init(&console_structure_kernel, &empty_tag, IPC_CONSOLE_CONNECTION_CLASS_CLIENT) != CONSOLE_RETURN_SUCCESS) { return; } - if (console_open(&console_structure_kernel, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) != - CONSOLE_RETURN_SUCCESS) + if (console_open(&console_structure_kernel, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) != CONSOLE_RETURN_SUCCESS) { return; } @@ -222,8 +216,7 @@ static void handle_kernel_logging(void *argument UNUSED) { system_call_kernelfs_entry_read(&kernelfs_log); - log_add(&console_structure_kernel, " " PACKAGE_NAME " version " PACKAGE_VERSION " kernel console.", - ipc_log_print); + log_add(&console_structure_kernel, " " PACKAGE_NAME " version " PACKAGE_VERSION " kernel console.", ipc_log_print); } } From 0b2777222bae52d491736d66060be420f022159a Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 22:29:43 +0300 Subject: [PATCH 05/11] Let's log the timestamp also. This gives us a better picture of the time elapsed between log entries. It also enables us to understand in what order things really occur (since they might get logged in the wrong order). --- libraries/ipc/log.h | 2 ++ libraries/log/log.c | 1 + servers/system/log/log.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/ipc/log.h b/libraries/ipc/log.h index 9ad36941..95b7c0dc 100644 --- a/libraries/ipc/log.h +++ b/libraries/ipc/log.h @@ -26,4 +26,6 @@ typedef struct // How urgent is this log message? 0 is most urgent, and higher numbers are of less importance. unsigned int urgency; + + time_type timestamp; } ipc_log_print_type; diff --git a/libraries/log/log.c b/libraries/log/log.c index 54b0a313..177185be 100644 --- a/libraries/log/log.c +++ b/libraries/log/log.c @@ -72,6 +72,7 @@ return_type log_print_formatted(log_structure_type *log_structure, unsigned int va_end(arguments); ipc_log_print.urgency = urgency; + system_call_timer_read(&ipc_log_print.timestamp); string_copy_max(ipc_log_print.log_class, log_structure->log_class, IPC_LOG_MAX_CLASS_LENGTH); string_copy_max(ipc_log_print.message, output, IPC_LOG_MAX_MESSAGE_LENGTH); log(log_structure, &ipc_log_print); diff --git a/servers/system/log/log.c b/servers/system/log/log.c index d07230e9..b0bb27f4 100644 --- a/servers/system/log/log.c +++ b/servers/system/log/log.c @@ -79,7 +79,8 @@ static void log_add(console_structure_type *console, char *title, ipc_log_print_ urgency_colour[ipc_log_print->urgency][0], urgency_colour[ipc_log_print->urgency][1], urgency_colour[ipc_log_print->urgency][2]); - console_print_formatted(console, " [%s] %s ", ipc_log_print->log_class, ipc_log_print->message); + console_print_formatted(console, " [%u.%03u] [%s] %s ", (u32) ipc_log_print->timestamp / 1000, + (u32) ipc_log_print->timestamp % 1000, ipc_log_print->log_class, ipc_log_print->message); // Go to next line (with correct colour). */ console_attribute_set(console, CONSOLE_COLOUR_GRAY, CONSOLE_COLOUR_BLACK, CONSOLE_ATTRIBUTE_RESET); From 93b03958822da955497ca2fcc1b9274e24f507e6 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 22:36:19 +0300 Subject: [PATCH 06/11] Whitespace changes. --- libraries/file/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/file/file.c b/libraries/file/file.c index 38206f21..ccbeb698 100644 --- a/libraries/file/file.c +++ b/libraries/file/file.c @@ -121,7 +121,6 @@ return_type file_read(ipc_structure_type *vfs_structure, file_handle_type file_h message_parameter.data = buffer; message_parameter.length = read.bytes; - system_call_mailbox_receive(vfs_structure->input_mailbox_id, - &message_parameter); + system_call_mailbox_receive(vfs_structure->input_mailbox_id, &message_parameter); return FILE_RETURN_SUCCESS; } From 3e9b34161bb1dea1f14fc42dbba70c5177e41c89 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 22:53:49 +0300 Subject: [PATCH 07/11] Whitespace fix. --- servers/file_system/fat/handle_connection.c | 1 - 1 file changed, 1 deletion(-) diff --git a/servers/file_system/fat/handle_connection.c b/servers/file_system/fat/handle_connection.c index 525544b6..13ee1b1a 100644 --- a/servers/file_system/fat/handle_connection.c +++ b/servers/file_system/fat/handle_connection.c @@ -173,4 +173,3 @@ void handle_connection(mailbox_id_type *reply_mailbox_id) } } } - From 9bba43ff91b27931435ec2dc89c2e3bcb62712fd Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 23:16:59 +0300 Subject: [PATCH 08/11] Mounted is better in this case. It's actually already mounted when the message is logged. --- servers/file_system/virtual_file_system/virtual_file_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/file_system/virtual_file_system/virtual_file_system.c b/servers/file_system/virtual_file_system/virtual_file_system.c index 840e421f..a231af9b 100644 --- a/servers/file_system/virtual_file_system/virtual_file_system.c +++ b/servers/file_system/virtual_file_system/virtual_file_system.c @@ -452,7 +452,7 @@ static bool vfs_mount(file_mount_type *mount, ipc_structure_type *ipc_structure) string_copy_max(mount_point[mounted_volumes].location, mount->location, MAX_PATH_NAME_LENGTH); mounted_volumes++; - log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE, "Mounting %u at //%s.", + log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE, "Mounted %u at //%s.", ipc_structure->output_mailbox_id, mount->location); return TRUE; } From fc4cf78d7b013174c5356d2ac8430e129e0dcdb3 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 23:29:24 +0300 Subject: [PATCH 09/11] Added an extra ipc_send/ipc_receive pair. The reason is to get more predicable order of messages being printed in the log. It feels silly that the boot server goes on with its work before the vfs server has ACKnowledged that the mount has been done. --- servers/file_system/virtual_file_system/virtual_file_system.c | 1 + servers/system/boot/boot.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/servers/file_system/virtual_file_system/virtual_file_system.c b/servers/file_system/virtual_file_system/virtual_file_system.c index a231af9b..5d074a75 100644 --- a/servers/file_system/virtual_file_system/virtual_file_system.c +++ b/servers/file_system/virtual_file_system/virtual_file_system.c @@ -529,6 +529,7 @@ static void handle_connection(mailbox_id_type *reply_mailbox_id) file_mount_type *mount = (file_mount_type *) data; vfs_mount(mount, &ipc_structure); + ipc_send(ipc_structure.output_mailbox_id, &message_parameter); break; } diff --git a/servers/system/boot/boot.c b/servers/system/boot/boot.c index 75542ad2..fb7d67ae 100644 --- a/servers/system/boot/boot.c +++ b/servers/system/boot/boot.c @@ -81,13 +81,15 @@ int main(void) // mount.mailbox_id = mailbox_id[0]; string_copy(mount.location, "ramdisk"); - // That's it. Send the message. + // That's it. Send the message. The receive is here just to ensure that we don't keep on going before the volume is + // actually mounted. message_parameter.protocol = IPC_PROTOCOL_FILE; message_parameter.message_class = IPC_FILE_MOUNT_VOLUME; message_parameter.data = &mount; message_parameter.length = sizeof (file_mount_type); message_parameter.block = TRUE; ipc_send(vfs_structure.output_mailbox_id, &message_parameter); + ipc_receive(vfs_structure.input_mailbox_id, &message_parameter, NULL); log_print(&log_structure, LOG_URGENCY_DEBUG, "Mounted the first available block service as //ramdisk."); From fdc9638a714278d83b4675fb50b287834c065b76 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 27 May 2015 23:42:30 +0300 Subject: [PATCH 10/11] Whitespace-only edit. --- servers/system/boot/boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/system/boot/boot.c b/servers/system/boot/boot.c index fb7d67ae..c64a9d00 100644 --- a/servers/system/boot/boot.c +++ b/servers/system/boot/boot.c @@ -86,7 +86,7 @@ int main(void) message_parameter.protocol = IPC_PROTOCOL_FILE; message_parameter.message_class = IPC_FILE_MOUNT_VOLUME; message_parameter.data = &mount; - message_parameter.length = sizeof (file_mount_type); + message_parameter.length = sizeof(file_mount_type); message_parameter.block = TRUE; ipc_send(vfs_structure.output_mailbox_id, &message_parameter); ipc_receive(vfs_structure.input_mailbox_id, &message_parameter, NULL); From deda5cdf1f8537ef7d9ab9d9dce57d7a3fb49386 Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Thu, 28 May 2015 00:17:39 +0300 Subject: [PATCH 11/11] Added missing system_call_timer_read invocation. --- libraries/log/log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/log/log.c b/libraries/log/log.c index 177185be..d4586827 100644 --- a/libraries/log/log.c +++ b/libraries/log/log.c @@ -86,6 +86,7 @@ return_type log_print(log_structure_type *log_structure, unsigned int urgency, c ipc_log_print_type ipc_log_print; ipc_log_print.urgency = urgency; + system_call_timer_read(&ipc_log_print.timestamp); string_copy_max(ipc_log_print.log_class, log_structure->log_class, IPC_LOG_MAX_CLASS_LENGTH); string_copy_max(ipc_log_print.message, message, IPC_LOG_MAX_MESSAGE_LENGTH);