From: Kevin Day Date: Sat, 25 Sep 2021 05:15:16 +0000 (-0500) Subject: Bugfix: Fix problems exposed due to testing and improve "Init". X-Git-Tag: 0.5.6~38 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=016e9f69523a821c1907741ef019876b22ab40c2;p=fll Bugfix: Fix problems exposed due to testing and improve "Init". As expected, I have found several regressions as a result of the mass conversion to fl_print_format() and similar. There are several places where the wrong parameters or string replacements are used. Improve the Controller to allow for "Init" to not attempt to mount the pid file (which allows Init to also manage initial mounting and device creation without depending on the existence of the filesystem structure). The Controllerr "Init" now treats an empty string for the --pid option as disabling the pid file creation. Do not treat exiting as a result from interrupts as an exit error. --- diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 48e59fe..90ca08f 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -46,6 +46,8 @@ extern "C" { fl_print_format(" The default interrupt behavior is to operate as if the %[%s%s%] parameter is passed.%c%c", main.output.stream, main.context.set.notable, f_console_symbol_long_enable_s, main.setting_default.used ? controller_long_uninterruptable : controller_long_interruptable, main.context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + fl_print_format(" Specify an empty string for the %[%s%s%] parameter to disable pid file creation for this program.%c%c", main.output.stream, main.context.set.notable, f_console_symbol_long_enable_s, controller_long_pid, main.context.set.notable, f_string_eol_s[0], f_string_eol_s[0]); + funlockfile(main.output.stream); return F_none; @@ -230,21 +232,12 @@ extern "C" { } } else { - if (main->warning.verbosity == f_console_verbosity_debug) { - flockfile(main->warning.to.stream); - - fl_print_format("%c%[%SThe parameter '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context); - fl_print_format("%[%s%s%]", main->warning.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_pid, main->context.set.notable); - fl_print_format("%[' must be a file path but instead is an empty string, falling back to the default.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); - - funlockfile(main->warning.to.stream); - } + main->process_pid = F_false; } } } - // a pid file path is required. - if (F_status_is_error_not(status) && !setting.path_pid.used) { + if (F_status_is_error_not(status) && !setting.path_pid.used && main->process_pid) { if (main->parameters[controller_parameter_init].result == f_console_result_found) { status = f_string_append(controller_path_pid_init, controller_path_pid_init_length, &setting.path_pid); diff --git a/level_3/controller/c/controller.h b/level_3/controller/c/controller.h index fc04756..9703a2a 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -221,6 +221,7 @@ extern "C" { f_array_lengths_t remaining; bool process_pipe; + bool process_pid; f_file_t output; fll_error_print_t error; @@ -244,6 +245,7 @@ extern "C" { controller_console_parameter_t_initialize, \ f_array_lengths_t_initialize, \ F_false, \ + F_true, \ macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \ fll_error_print_t_initialize, \ macro_fll_error_print_t_initialize_warning(), \ diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index d68197a..a1436c2 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -37,6 +37,7 @@ int main(const int argc, const f_string_t *argv) { // when run as "init" by default, provide the default system-level init path. // this change must only exist within this main file so that the change only exists within the program rather than the library. #ifdef _controller_as_init_ + data.process_pid = F_false; data.program_name = controller_name_init; data.program_name_long = controller_name_init_long; data.setting_default.string = controller_path_settings_init; @@ -68,7 +69,11 @@ int main(const int argc, const f_string_t *argv) { } if (F_status_is_error(status)) { - return 1; + + // do not return error when interrupt was received. + if (F_status_set_fine(status) != F_interrupt) { + return 1; + } } return 0; diff --git a/level_3/controller/c/private-common.c b/level_3/controller/c/private-common.c index 6b4dc6a..f8d829e 100644 --- a/level_3/controller/c/private-common.c +++ b/level_3/controller/c/private-common.c @@ -319,16 +319,16 @@ extern "C" { fl_print_format(" %['due to%] ", print.to.stream, print.context, print.context); if (status == F_parameter) { - fl_print_format("%[%s%]", print.to.stream, print.notable, "Invalid Parameter", print.notable); + fl_print_format("%[Invalid Parameter%]", print.to.stream, print.notable, print.notable); } else if (status == F_deadlock) { - fl_print_format("%[%s%]", print.to.stream, print.notable, "Deadlock", print.notable); + fl_print_format("%[Deadlock%]", print.to.stream, print.notable, print.notable); } else if (status == F_resource_not) { - fl_print_format("%[%s%]", print.to.stream, print.notable, "Too Many Locks", print.notable); + fl_print_format("%[Too Many Locks%]", print.to.stream, print.notable, print.notable); } else { - fl_print_format("%[%s%]", print.to.stream, print.notable, "Unknown Error", print.notable); + fl_print_format("%[Unknown Error%]", print.to.stream, print.notable, print.notable); } } diff --git a/level_3/controller/c/private-controller.c b/level_3/controller/c/private-controller.c index 55d83ce..b09425e 100644 --- a/level_3/controller/c/private-controller.c +++ b/level_3/controller/c/private-controller.c @@ -413,7 +413,7 @@ extern "C" { f_status_t status = F_none; // only create pid file when not in validate mode. - if (is_entry && global.main->parameters[controller_parameter_validate].result == f_console_result_none) { + if (is_entry && global.main->parameters[controller_parameter_validate].result == f_console_result_none && global.main->process_pid) { status = controller_file_pid_create(global.main->pid, global.setting->path_pid); @@ -575,7 +575,7 @@ extern "C" { fl_print_format("%c%[%SThe %s item named '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.prefix, global.main->error.context); fl_print_format("%[%Q%]", global.main->error.to.stream, global.main->error.notable, entry->items.array[i].name, global.main->error.notable); - fl_print_format("%[' cannot be executed because recursion is not allowed.%]%c", global.main->error.to.stream, global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); + fl_print_format("%[' cannot be executed because recursion is not allowed.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->error, cache->action); @@ -641,7 +641,7 @@ extern "C" { fl_print_format("%c%[%SThe %s item named '%]", global.main->error.to.stream, f_string_eol_s[0], global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.prefix, global.main->error.context); fl_print_format("%[%Q%]", global.main->error.to.stream, global.main->error.notable, actions->array[cache->ats.array[at_j]].parameters.array[0], global.main->error.notable); - fl_print_format("%[' does not exist.%]%c", global.main->error.to.stream, global.main->error.context, is_entry ? controller_string_entry_s : controller_string_exit_s, global.main->error.context, f_string_eol_s[0]); + fl_print_format("%[' does not exist.%]%c", global.main->error.to.stream, global.main->error.context, global.main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global.main->error, cache->action); @@ -836,7 +836,7 @@ extern "C" { flockfile(output->to.stream); - fl_print_format("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_format("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->context, output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s, output->context); fl_print_format("%[%Q%]", output->to.stream, output->notable, cache->action.name_action, output->notable); if (entry_action->parameters.used) { @@ -873,7 +873,7 @@ extern "C" { flockfile(output->to.stream); - fl_print_format("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s); + fl_print_format("%c%[%SThe %s item action '%]", output->to.stream, f_string_eol_s[0], output->context, output->prefix ? output->prefix : f_string_empty_s, is_entry ? controller_string_entry_s : controller_string_exit_s, output->context); fl_print_format("%[%Q%]", output->to.stream, output->notable, cache->action.name_action, output->notable); if (entry_action->parameters.used) { @@ -1250,7 +1250,7 @@ extern "C" { fl_print_format("%c%[%SExecution failed, unable to find program or script '%]", global->main->error.to.stream, f_string_eol_s[0], global->main->error.context, global->main->error.prefix ? global->main->error.prefix : f_string_empty_s, global->main->error.context); fl_print_format("%[%Q%]", global->main->error.to.stream, global->main->error.notable, entry_action->parameters.array[0], global->main->error.notable); - fl_print_format("$['.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]); + fl_print_format("%['.%]%c", global->main->error.to.stream, global->main->error.context, global->main->error.context, f_string_eol_s[0]); controller_entry_error_print_cache(is_entry, global->main->error, cache->action); diff --git a/level_3/controller/c/private-entry.c b/level_3/controller/c/private-entry.c index 04915f1..3395785 100644 --- a/level_3/controller/c/private-entry.c +++ b/level_3/controller/c/private-entry.c @@ -735,7 +735,7 @@ extern "C" { if (cache.name_action.used) { fl_print_format("action '%]", output.to.stream, output.context); - fl_print_format("%[%Q%]", output.to.stream, output.context, cache.name_action, output.context); + fl_print_format("%[%Q%]", output.to.stream, output.notable, cache.name_action, output.notable); fl_print_format("%[' on line%] ", output.to.stream, output.context, output.context); fl_print_format("%[%un%]", output.to.stream, output.notable, cache.line_action, output.notable); fl_print_format("%[ for ", output.to.stream, output.context); diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index 169566a..5a0d533 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -425,7 +425,6 @@ extern "C" { controller_error_print(global.main->error, F_status_set_fine(status), "f_fss_count_lines", F_true, global.thread); } else { - actions->array[actions->used].type = type; actions->array[actions->used].line += ++item->line; actions->array[actions->used].parameters.used = 0; @@ -694,17 +693,17 @@ extern "C" { fl_print_format("%c%[%SWhile processing ", output.to.stream, f_string_eol_s[0], output.context, output.prefix); if (cache.name_action.used) { - fl_print_format("%s '%]", output.to.stream, output.context, item ? controller_string_action_s : controller_string_value_s, output.context); + fl_print_format("%s '%]", output.to.stream, item ? controller_string_action_s : controller_string_value_s, output.context); fl_print_format("%[%Q%]", output.to.stream, output.notable, cache.name_action, output.notable); - fl_print_format("%[ on line %]", output.to.stream, output.context, output.context); + fl_print_format("%[' on line%] ", output.to.stream, output.context, output.context); fl_print_format("%[%un%]", output.to.stream, output.notable, cache.line_action, output.notable); fl_print_format("%[ for ", output.to.stream, output.context); } if (cache.name_item.used) { - fl_print_format("rule %s '%]", output.to.stream, output.context, item ? controller_string_item_s : controller_string_setting_s, output.context); + fl_print_format("rule %s '%]", output.to.stream, item ? controller_string_item_s : controller_string_setting_s, output.context); fl_print_format("%[%Q%]", output.to.stream, output.notable, cache.name_item, output.notable); - fl_print_format("%[ on line %]", output.to.stream, output.context, output.context); + fl_print_format("%[' on line%] ", output.to.stream, output.context, output.context); fl_print_format("%[%un%]", output.to.stream, output.notable, cache.line_item, output.notable); fl_print_format("%[ for ", output.to.stream, output.context); } @@ -5580,7 +5579,7 @@ extern "C" { } else { for (k = 0; k < action->parameters.used; ++k) { - fl_print_format(" %s%s%s %Q%c", main->output.stream, main->context.set.important, controller_string_parameter_s, main->context.set.important, action->parameters.array[k], f_string_eol_s[0]); + fl_print_format(" %[%s%] %Q%c", main->output.stream, main->context.set.important, controller_string_parameter_s, main->context.set.important, action->parameters.array[k], f_string_eol_s[0]); } // for } diff --git a/level_3/controller/data/settings/entries/default.entry b/level_3/controller/data/settings/entries/default.entry index 231023a..ad102ec 100644 --- a/level_3/controller/data/settings/entries/default.entry +++ b/level_3/controller/data/settings/entries/default.entry @@ -19,7 +19,6 @@ main: boot: start boot filesystem require start boot modules require - start boot devices require start service logger wait start service dbus asynchronous @@ -40,8 +39,4 @@ console: start service mouse maintenance: - timeout start 2 - timeout stop 2 - timeout kill 2 - - start maintenance console + execute bash --login diff --git a/level_3/controller/data/settings/entries/maintenance.entry b/level_3/controller/data/settings/entries/maintenance.entry new file mode 100644 index 0000000..ebab568 --- /dev/null +++ b/level_3/controller/data/settings/entries/maintenance.entry @@ -0,0 +1,7 @@ +# fss-0005 +# +# A boot to bash process. +# + +main: + execute bash --login diff --git a/level_3/controller/data/settings/rules/boot/devices.rule b/level_3/controller/data/settings/rules/boot/devices.rule deleted file mode 100644 index f165c5d..0000000 --- a/level_3/controller/data/settings/rules/boot/devices.rule +++ /dev/null @@ -1,9 +0,0 @@ -# fss-000d -# -# Rule for initializing the device files. -# - -setting: - name "Setup System Devices" - - on start need boot modules diff --git a/level_3/controller/data/settings/rules/program/terminal.rule b/level_3/controller/data/settings/rules/program/terminal.rule index 50fbcb3..99dd544 100644 --- a/level_3/controller/data/settings/rules/program/terminal.rule +++ b/level_3/controller/data/settings/rules/program/terminal.rule @@ -2,27 +2,28 @@ # # Rule for the terminal programs. # +# -m = don't prompt for login. setting: name "System Terminal" capability "all=" -service: - pid_file /var/run/tty/tty1.pid +command: + #pid_file /var/run/tty/tty1.pid - start qingy tty1 -d -l -n -t + start agetty -8 9600 tty1 linux -service: - pid_file /var/run/tty/tty2.pid +command: + #pid_file /var/run/tty/tty2.pid - start qingy tty2 -d -l -n -t + start agetty -8 9600 tty2 linux -service: - pid_file /var/run/tty/tty3.pid +command: + #pid_file /var/run/tty/tty3.pid - start qingy tty3 -d -l -n -t + start agetty -8 9600 tty3 linux -service: - pid_file /var/run/tty/tty4.pid +command: + #pid_file /var/run/tty/tty4.pid - start qingy tty4 -d -l -n -t + start agetty -8 9600 tty4 linux diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index a0c0160..87711f2 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -368,10 +368,10 @@ extern "C" { flockfile(main.error.to.stream); fl_print_format("%c%[%SThe section operation '%]", main.error.to.stream, f_string_eol_s[0], main.error.context, main.error.prefix, main.error.context); - fl_print_format("%[%Q%]", main.error.to.stream, main.error.notable, operation_name, main.error.notable); + fl_print_format("%[%/Q%]", main.error.to.stream, main.error.notable, buffer, operation_name, main.error.notable); fl_print_format("%[' from section '%]", main.error.to.stream, main.error.context, main.error.context); - fl_print_format("%[%Q%]", main.error.to.stream, main.error.notable, section_name, main.error.notable); - fl_print_format("%[' on line %]", main.error.to.stream, main.error.context, main.error.context); + fl_print_format("%[%/Q%]", main.error.to.stream, main.error.notable, buffer, section_name, main.error.notable); + fl_print_format("%[' on line%] ", main.error.to.stream, main.error.context, main.error.context); fl_print_format("%[%un%]", main.error.to.stream, main.error.notable, line, main.error.notable); fl_print_format(" %[failed.%]%c", main.error.to.stream, main.error.context, main.error.context, f_string_eol_s[0]);