Kevin Day [Wed, 26 May 2021 01:45:00 +0000 (20:45 -0500)]
Feature: The install.sh script should support disabling installation of headers.
If any headers exist, there still may be a desire to not install headers.
One such example is separately install static files to one location and shared to another using separate calls.
The headers may also be installed in only one of those or another separate call.
Kevin Day [Tue, 25 May 2021 23:27:30 +0000 (18:27 -0500)]
Feature: Add Unicode to/from UTF-8 translations and fix usage of function that should be private.
This logic has not actually been tested yet.
This needs to be reviewed for endianess correctness.
All of the UTF-8 processing code, in fact, needs to be reviewed for endianess so I decided to not test this further until I can review and correct the big vs little endianness support.
Kevin Day [Thu, 20 May 2021 02:39:45 +0000 (21:39 -0500)]
Regression: "fake skeleton" no longer works due to "file not found".
ERROR: Unable to create file 'data/build/defines', could not find file.
This error message is a bit nonsensical because it is supposed to create a file if it does not exist.
This is a regression in that at some point f_file_is() started returning F_file_found_not with error bit set and the skeleton program is only expecting F_file_found_not without the error bit set.
Make the test error-bit neutral.
Kevin Day [Wed, 19 May 2021 03:48:26 +0000 (22:48 -0500)]
Progress: Interrupt and memory allocation related changes.
I've noticed that when processing large files, the FSS programs cannot be interrupted using controlled interrupts rather than the standard interrupt signals.
The POSIX standard structure of interrupts, particularly in threads, is very poorly defined.
When a threaded program wishes to be triggered for an exit, the pthread_cancel() function works by immediately exiting the program rather than aborting.
This prevents proper deallocated and shutting down of programs, particularly those that handle interrupts.
This introduces a new f_state_t structure that allows passing a generalized state around that accepts (void *) arguments so that it is not tied to any particular implementation beyond the basic structure.
The FLL/FSS and IKI processing functions then take advantage of this and utilize the state.
There are performance concerns with this, but the need to have controlled interrupts is deemed far more important.
Furthermore, the generic function is open ended so that the caller can potentially implement some sort of optimization.
Now that an f_state_t structure exists I am finally compelled to move the allocation step functionality into this structure.
This will allow for more performance improvements (such as determining allocation step according to file size).
For large files (megabytes, gigabytes, etc..) the allocation step can be set to something large, such as 16384.
Doing so should reduce the amount of memory I/O needed for resize operations.
I have opted to use uint16_t, so there is a max step of 64k at this time.
This entire process needs additional reviewing before releasing.
I designed this with the intent to move the function parameters into the (void *) data property on the f_state_t structure.
This will allow for reducing the parameters passed.
This design will also allow for me to later on add additional state information that can be passed to the caller.
This also allows for better or more granular error handling and reporting.
More work is needed in this regard because many of the functions currently written need to utilize this (such as the recursive directory functions).
This focuses on the most basic utilization in the programs but I would like to perform file size tests so that I can at least have a very basic heuristic for determining the default allocation size for large (or small) files.
A new project fl_signal is provided with a basic interrupt callback for f_state_t as I believe a dirt simple callback will be commonly used.
The default allocation step is now broken up into large and small allocation steps.
Kevin Day [Tue, 11 May 2021 23:11:59 +0000 (18:11 -0500)]
Feature: The install.sh should helper script should allow more granular installations between shared and static.
Add new parameters "--disable-shared-programs", "--disable-shared-libraries", "--disable-static-programs", and "--disable-static-libraries".
These parameters will enable/disable shared/static libraries/programs.
Both shared and static may be compiled and this allows for choosing to install which of those to install.
Kevin Day [Sat, 8 May 2021 01:11:19 +0000 (20:11 -0500)]
Feature: Add support for determining columns in FSS Read programs.
Implement a new feature for determining how many columns total are available for some Content.
Update the specifications accordingly.
The term "columns" has been added to designate this concept of the now of column sets within some Content.
Previously, this was weakly named.
The select functionality "--select" allows for selecting these columns but there has been no way to know how many columns exist.
This is not a good design for scripting and similar usage.
By providing a total number of columns, the select function becomes more complete and useful.
When columns is specified without any particular Object specified, then the maximum columns length for all Content is printed.
Kevin Day [Fri, 7 May 2021 22:11:00 +0000 (17:11 -0500)]
Bugfix: The install.sh should allow for -w to be used when destination_prefix is invalid.
While buildin a system from scratch, the default destination does not exist.
This exposed a bug where the script complains about the destination directory even when the destination directory is not to be used (because the work directory is being used).
Kevin Day [Fri, 7 May 2021 05:22:33 +0000 (00:22 -0500)]
Update: Provide defines for disabling less-portable code exposed as a problem when using musl-libc.
The f_thread project utilizes several pthread functions that are non-portable.
Add some initial support for disabling these and do disable these by default.
I intend to expand upon this and adding more defines.
The current ones might be renamed.
Kevin Day [Fri, 7 May 2021 04:33:08 +0000 (23:33 -0500)]
Bugfix: Compilation/Portability problems exposed when building against musl-libc.
Some headers are missing.
Change the length types: f_console_parameter_size and f_array_length_t.
I have seen problems where the max allowed size is reached in f_array_length_t.
Compiling against musl-libc further exposes this problem and so I have reduced the practice to using a set length of 2^63 (aka: signed long).
Kevin Day [Fri, 7 May 2021 00:12:32 +0000 (19:12 -0500)]
Bugfix: Fix problems revealed when working on FSS Extended List Read.
Be sure to explicitly check data->objects.used is non-zero when counting total.
The Basic List and Extended List Object names, when being selected (via the --select parameter), should be trimmed by default.
This is because the Basic List nd Extended List standards define an Object name as beginning after on the first non-whitespace and ending at the last non-whitespace.
Minor syntax cleanups such as replaced "if (X > 0)" with "if (X)".
Kevin Day [Fri, 7 May 2021 00:09:32 +0000 (19:09 -0500)]
Security: FSS Read functions should check range before buffer.
The range may have exceeded the buffer or the stop point.
There is a string test that happens before this is checked.
If this string is checked with an out of range address, then a segfault could occur.
Kevin Day [Thu, 6 May 2021 22:40:43 +0000 (17:40 -0500)]
Bugfix: FSS Extended List is not detecting end properly.
If the content is something like:
example {
}
There is no Content.
This is not being detected correctly an the '}' is being included.
There are two problems here:
1) The current position at the end should be after the eol and not that last newline.
2) If the current position matches the start position, then it needs to be explicitly designated as empty.
Kevin Day [Thu, 6 May 2021 01:09:43 +0000 (20:09 -0500)]
Bugfix: FSS Basic Read and FSS Basic List Read problems and cleanups.
The delimit is not being calculated correctly.
The fss_basic_read_load() and fss_basic_list_read_load functions are out of place.
The parameter order for some functions like fss_basic_read_print_at() are not adhering to the ordering practices (constants on the left).
The total is not consistently being counted.
The FSS Basic Read is not taking into consideration when Content is empty and --object is or is not selected for some line specific processing.
When there is only --content, then whether or not Content is empty matters.
When there is --object (or both --object and --content), then whether or not Content is empty does not matter because Object is already taking up a given line.
Kevin Day [Wed, 5 May 2021 05:24:12 +0000 (00:24 -0500)]
Cleanup: Use number instead of word in FSS Basic Read help.
While committing the FSS Basic List changes to be in sync with this, I noticed that I had "..start at 0 instead of one..".
This is inconsistent.
I either need to use both words ("zero" and "one") or both numbers ("0" and "1").
I opted to use the numbers.
Kevin Day [Wed, 5 May 2021 05:13:35 +0000 (00:13 -0500)]
Update: Improvements and tweaks in FSS Basic Read.
Add additional help information.
Cleanup comments.
In some cases the total printing is inverted by accident.
The print_object function pointer doesn't really need to exist anymore.
Add missing print for when both total and line parameters are specified.
Kevin Day [Wed, 5 May 2021 05:00:40 +0000 (00:00 -0500)]
Bugfix: UTF-8 characters buffer is incorrectly returning an error.
The previous commit: "Bugfix: UTF-8 characters are not being fully printed" exposed that for UTF-8 characters (width 2 or greater), an error is always returned.
When the width properly fits in the requested range, return the appropriate success code instead of an error.
The previous implementation is weak in that there is no good way to just delimit Object or just delimit Content.
Redesign to allow for specifying the delimit parameter multiple times and therefore allow for customizing what to specify.
Rename "depth" to "content" in the delimit enum to better communicate that this is for "content" delimiting.
Examples:
- "fss_basic_read --delimit object": Results in delimited Objects but not Content.
- "fss_basic_read --delimit 0+": Results in delimited Content (position 0 and greater) but not Objects.
- "fss_basic_read --delimit object --delimit 1-": Results in delimited Objects and delimit Content (position 1 or less).
For this standard, there is no delimit support in Content so the use of the numeric range is superfluous.
Having this functionality, however, makes it consistent with the rest of the FSS Read programs.
Kevin Day [Mon, 3 May 2021 02:51:54 +0000 (21:51 -0500)]
Regression: FSS Basic read --select is always returning empty sting or 0.
After changing the code structure, the check to see if the select number is non-zero was lost.
As a result the code is always operating as if the select number is non-zero.
When the select number is zero, all existing operations should continue.
I seem to have forgotten to wrap these macro checks in parenthesis.
As a result something like "!macro_f_file_type_is_block()" would expand to "!macro_f_file_type_get(mode) == f_file_type_block".
What it should expand to should be logically equivalent to "macro_f_file_type_get(mode) != f_file_type_block".
The expansion with the parenthesis would be: "!(macro_f_file_type_get(mode) == f_file_type_block)" and that is indeed logically equivalent.
Kevin Day [Mon, 3 May 2021 02:10:40 +0000 (21:10 -0500)]
Cleanup: Disable parenthesis warning in GCC.
This is another case where the compiler is overstepping itself.
The programmer should understand the language and the order of operations.
Disable the warning by passing -Wno-parentheses.
(The warning only appears if -Wall is given, but if -Wall is passed then -Wno-parentheses should be already in place.)
Kevin Day [Mon, 3 May 2021 02:07:21 +0000 (21:07 -0500)]
Cleanup: Sloppy use of "main" inside of "main()", oops.
I cannot believe I let this one slip through (and so did the compilers).
When I refactored "data" to be "main" this included the refactor in the function called "main".
This is dangerous at worst and at best bad practice.
Given that "data" is no longer to be used in the main(), just rename the uses of "main" back to "data" for the variable name only (not the typedef structure name).
Kevin Day [Mon, 3 May 2021 01:53:48 +0000 (20:53 -0500)]
Cleanup: FSS Basic Read parameter processing, file variable related, and some ++/--.
Simplify the parameter processing using an array to avoid repeating similar code.
Relocate the file variable so that it goes out of scope and is removed from the stack before processing.
The file variable is no longer needed during processing with the current design so don't hold it in memory after it is no longer needed.
Relocate the file stream close so that it doesn't need to be specified as many times in the code.
There are some ++/-- postfixes in use that would be better as prefixes (such as changing i++ to ++i).
Kevin Day [Sun, 2 May 2021 22:09:43 +0000 (17:09 -0500)]
Update: Implement data structure in FSS Read.
This is the designated follow up commit for resolving the need for a "data" structure.
The parameters are now extracted into a bitwise "option" property on the "data" structure.
The process is now broken up into multiple functions.
Kevin Day [Sun, 2 May 2021 05:12:42 +0000 (00:12 -0500)]
Update: Remove the "amount" from file stream functions.
The "amount" is present to support the parameters that fread() and fwrite() utilize.
This makes no sense to me and it is annoying and confusing.
I end up having to just put 1.
Get rid of it and just use the file.size_read and file.size_write to specify the buffer size to read/write.
The only things that I can thing of might be atomic operations, locking, and calling the function multiple times.
These are good reasons to have an "amount".
If I end up wanting o needing an "amount", I may add additional functions later on.
Kevin Day [Sat, 1 May 2021 22:31:49 +0000 (17:31 -0500)]
Cleanup: Always have private-common.h and private-common.c for programs.
I am now introducing a new standard practice of always having a private-common.h and private-common.c for programs.
The private data types shared across the program will be stored in these.
These will also provide any functions for allocating, deallocating, or otherwise managing those private structures.
This makes no effort to move over or implement any of the allocation/deallocation functions.
Individual programs will be updated on an as able basis to address this.
The Controller program already has this but it has a bit more than this practice.
The Controller program will see some structural cleanup in the future.
Kevin Day [Sat, 1 May 2021 22:00:27 +0000 (17:00 -0500)]
Refactor: Relocate 'macro' prefix in names for macros.
Placing 'macro' after the project name, such as 'fll_' or 'fake_', is a good idea for keeping the function names consistent and contained within the project naming structure.
For short names like 'f_' and 'f_string_t' this is not a problem.
For complex and usually longer names, such as 'fake_' and 'fake_main_t', this becomes confusing quickly,
I have decided to favor the less consistent macro as a prefix to the project name, to make the code a bit more readable.
For example: 'fake_main_macro_delete' would become 'macro_fake_main_delete".
Kevin Day [Sat, 1 May 2021 21:46:35 +0000 (16:46 -0500)]
Refactor: Use 'main' instead of 'data'.
The original goal of 'data' is to be used as the main store of data for the program.
A program using the programs as a library are also expected to get and use this structure.
The problem is that the programs are designed such that the caller to the program (as a library) should not have access to internal details.
Refactor 'data' to 'main'.
This is a more precise name in that it is the structure passed as if it were called from 'main(argc, argv)'.
This also frees up 'data' for internal use such that 'data' can now be the more generalized 'data' without exposing anything to 'main'.
The Controller program is already using 'main', so that 'main' was refactored to 'global'.
There are still more changes to do, such as restructuring the 'main' types to ensure nothing unwanted is exposed to a caller.
These additional changes, however, are beyond this scope of this commit.
Kevin Day [Sat, 1 May 2021 19:46:21 +0000 (14:46 -0500)]
Bugfix: Several of the parameters are not handling the desired set of possible combinations.
With recent changes, more parameters may be used together than before.
This exposed how several combinations simply did nothing or did not do what was expected.
Redesign and even simplify the code to allow these parameters to work together.
Some of the code is abstracted out into their own functions.
There is a goal to have a data structure for passing setting, but before that is done I want to make other significant changes FLL-wide.
For this reason, I am putting in place a temporary 'print_this' bitwise variable.
Kevin Day [Sat, 1 May 2021 16:23:56 +0000 (11:23 -0500)]
Update: Redesign Basic List loading logic to load all files into a single buffer.
Upon further use and review I believe that it is better to treat all input sources as a single buffer.
This allows for all of the parameters to work closer to what feels like normal logic.
If I want to get the total lines for all listed files, then I should get that.
If I want to get the total lines for each listed file, then I can call this program once for each file to get that.
I am working on Basic List first but this will be repeated for all of the other FSS read projects as well (likely in a single commit).
One of the downsides of this is that it exposes a current design limitation where the max buffer size is more likely to be reached.
Future work will most likely address this in some manner.
Kevin Day [Sat, 1 May 2021 03:46:02 +0000 (22:46 -0500)]
Regression: Incorrect char type resulted in SIGPIPE.
The uint8_t/int8_t was changed into char recently.
This change appears to have be incomplete for the Byte Dump program.
Update the code to be aware of PIPE by passing a NULL string to represent a PIPE instead of a file.
While fixing this, go ahead and replace read() with fgetc().
This is more efficient due to the use of a file stream.
The use of read() is originally done for testing some of the lower-level FLL design.
This testing is no longer necessary so it is worth switching to fgetc().
Future design may merit reading larger chunks than 1 character at a time.
The use of fseek() is now available and in use (for non-PIPEs).
Kevin Day [Wed, 28 Apr 2021 23:57:36 +0000 (18:57 -0500)]
Update: Replace static strings with extern defined in common file.
This makes the controller program more consistent with the FLL projects.
This should make it easier to use the controller program as a library as well.
Kevin Day [Wed, 28 Apr 2021 23:08:29 +0000 (18:08 -0500)]
Update: Fix problems and make changes after testing LLVM's Clang compiler.
Add flags "-Wno-logical-not-parentheses" "-Wno-logical-op-parentheses".
Programmers should be expected to understand the language they are working.
Having the compiler for a style is bad practice.
The cap_to_text() needs ssize_t, do not use f_array_length_t.
The project is inconsistently using int8_t and uint8_t for character types.
Furthermore, clang likes to complain about uint8_t being converted to char.
(I believe uint8_t is supposed to be of type unsigned char and char by default is supposed to be unsigned.)
Fix the inconsistency and just use char, which happens to make clang happy without any complaints from gcc.
Clang does a much better job at detecting some problems than GCC.
Compiling with clang resulted in revealing several printf related problems that now should be fixed.
The f_gcc_attribute_visibility_internal (and related) have the "_gcc" removed because these seem to exist beyond just gcc (such as with clang).
Make sure something is always returned.
There are some functions that didn't have a return.
One of the UTF processing functions has an accidental hex character in the condition.
Remove the extra character, which I am pretty sure is the leading "d".
I have not validated the correct sequence and so further investigation in the proper sequence for U+1D7CE to U+1D7D7 may be warranted.
The clang compiler claims that int main() should only be an integer for the argc.
This is unfortunate but that is fine, switch to use an int instead of an unsigned long.
Kevin Day [Tue, 27 Apr 2021 23:49:35 +0000 (18:49 -0500)]
Bugfix: PID and PID file should account for multiples during process execution.
I forgot all about needing to do this so I am considering this a bug.
Each process may execute multiple Actions.
Each Action has its own PID.
In the case of foreground (synchronous) execution, having only a single PID and PID file path on the Process structure is not a problem.
When with PID file (asynchronous) execution operates, multiple PIDs (and respective PID files) may exist for any single Process structure.
Kevin Day [Tue, 27 Apr 2021 04:09:09 +0000 (23:09 -0500)]
Regression: Entry error after failure or during validation is not propogating.
When an Entry fails and successfully executes a failsafe, the failure is not propagated.
The failsafe is meant to bail out and not continue onward, so after a successful or failed failsafe, return F_failure (with error bit as appropriate).
When passing --validate without --test, the program is not exiting as it should.
This is because the state is not being handled just like the status is not being handled.
When joining threads, be sure to reset the identifiers.
Remove now extra Exit processing block.
This is now handled fully by the cancellation function.
Restore the thread enabled state after operating failsafe.
Get rid of simulate variable, instead use the console parameter directly.
This saves memory by a trivial amount.
Kevin Day [Mon, 26 Apr 2021 23:45:23 +0000 (18:45 -0500)]
Update: Implement "execute" support and fix bugs.
Provide new feature for executing into another program.
This is provided via the new Item Action "execute".
The function controller_perform_ready() is being called and the status is being checked but the status is not being assigned.
There are a few cases where thread.enabled needs to be checked and a few cases it does not need to be checked.
Several of the threads need to be aware of the normal/other status to properly determine the thread.eneabled situation.
Without this, they make incorrect decisions that result in bugs.
I did not want to implement a new structure to resolve this so instead provide custom wrapper functions to call that set the appropriate normal/other state.
The functon controller_thread_process_cancel() now needs to be caller aware so that the caller does not get cancelled.
Kevin Day [Sun, 25 Apr 2021 17:13:54 +0000 (12:13 -0500)]
Update: Improve entry/exit verbose messages, display exit with -tv, and wait all with read lock fix.
The verbose messages should be distinguishing between an entry and an exit now.
When both --simulate and --test are specified, the printout should include both the entry and the exit.
Previously, only the entry was printed.
The wait all should only be triggered to wait for all processes at the current moment in time.
Furthermore, the read lock is being held too long (for the entire loop).
Maintain the read lock long enough to build a list of all processes to wait for.
Kevin Day [Fri, 23 Apr 2021 01:49:21 +0000 (20:49 -0500)]
Progress: redesign processing logic to accommodate different process Rule Actions and update dependency design accordingly.
When I implemented the "exit" support (opposite of an "entry") I noticed a oversight in the design whereas there was no way to distinguish between a process that successfully started via the "entry" or the "exit".
Change the design to now utilize unique Rule Processes for each Rule Action requested.
This required further changes to the status handling.
A rule status is now an array of all possible Rule Actions.
This is utilized using a static array for simplicity purposes (there is no need for a dynamic array here).
All of the recent changes introduced a lot more complex code.
There are now helper functions to help facility common tasks.
This should also make updating easier as there is only one place to update.
The downside is the introduction of an additional function call (which is a tiny runtime cost).
To facility this new design, the Rule files must also be aware of the different Rule Actions.
The "need", "want", and "wish" have been relocated into a new Rule Action called "on".
Additional parameters for an "on" allow for describing the Rule Action in which the dependency applies to.
This allows, for example, a "stop" Action to operate in a different order than a "start" Action.
An example of this is provided.
Look at the data/settings/example/rules/serial/*.rule files.
An example syntax is:
on start need serial s_1
on stop need serial s_3
When validate is passed, do not wait for asynchronous processes because they are not run.
Normally this is not noticeable but is exposed when 'script/fail' failed to execute and return ('script/fail' should execute, fail, and return).
This bug is caused by the wait functions not checking to see if the caller is the same as the current process (it was waiting for itself).
This may have been introduced as a result of the redesign.
Kevin Day [Wed, 21 Apr 2021 22:12:00 +0000 (17:12 -0500)]
Progress: Redesign enty/exit rule handling, now requiring Action instead of "rule".
The Entry and Exit files are using "rule" to designate a Rule to operate.
This is designed on the assumption that an Entry always runs a "start" and Exit always runs a "stop".
This behavior is changed such that "rule" is no longer specified and one of the 9 supported Actions may be used.
Such as "start" or "stop", for example.
There is still more work to do as this change doesn't fix the Exit in terms of dependency handling.
Currently, the process structure does not distinguish the Rule action, such as "start" or "stop".
Additional changes to the process structure are needed.
Kevin Day [Tue, 20 Apr 2021 23:16:45 +0000 (18:16 -0500)]
Progress: controller program, add exit support.
This implements the initial work needed to get exit files working.
A new thread is added to handle both "entry" and "exit" to free up the "rule" thread and allow for the "exit" to start will the "rule" thread exists.
The thread enabled process is now more complex given that there needs to be stages so that "exit" threads can work while "entry" or "control" operations begin terminating.
Add several helper functions to help simplify the detection.
Add an "alert" lock to send/receive alerts.
This is a more general purpose lock that tells something waiting on the alert to wake up and see if anything you care about changed.
The file loading now needs to be aware of "optional" files, namely the exit files.
If the named exit file does not exist, then do not care as it is not required (unlike entry and rule files).
Many of the read and write locks are now timed so that they can check to see if the controller is enabled or not.
While working on this I noticed some oversights and things that I did not previously consider.
I need to follow this up with a redesign in the entry/exit rule handling.
Instead of "rule", I should have the rule actions like "start" and "stop".
There needs to be support for default behaviors, such as allow for "stop" to not have a parameter and to correctly find and terminate a service.
There needs to be consideration on dependencies when exiting, perhaps there needs to be an exit-specific dependency management.
Kevin Day [Sun, 18 Apr 2021 15:47:12 +0000 (10:47 -0500)]
Progress: exit prep work, reserve and implement "setting" in entries and exits, add option to "ready', and update documentation.
Add documentation, specifications, and basic structural changes for the "exit" files.
The "entry" and "exit" files now reserve "setting" for designating settings.
Currently, only "entry" supports a setting and that setting is "mode".
The "mode" setting designates how the entry program is intended to behave.
When operating as a "service", the controller program will wait indefinitely for commands (via the not yet implemented "control" program or "control" socket).
When operating as a "program", the controller program will immediately exit after completion.
The "ready" Entry Action now supports "wait".
When "wait" is provided, the "ready" operation will wait for all current asynchronous processes to complete before operating.
Update documentation and specifications, adding the "exit" files.
Cleanup the existing documentation and specifications, fixing wording.
Kevin Day [Sat, 17 Apr 2021 23:44:52 +0000 (18:44 -0500)]
Update: implement with pid execution, simplify related rules.
Implement the with pid execution.
This expects the process to be spawned in the background.
After some review, I decided to remove "use" and "create", replacing those with "pid_file".
The reasons are:
- For "use", the spawned service manages the pid file, so it would be overly complicated to try and manage it in addition to the spawned service.
- For "create", if the process is to go into the background, in order to manage it then there would still need to be a running process (this defeats the purpose).
When the termination signal is received, then inform any background process spawned by the controller program to exit, based on the existence of the pid file.
Kevin Day [Sat, 17 Apr 2021 19:44:21 +0000 (14:44 -0500)]
Update: fix file stream error return, improve file error messages, add new status types and remove status types.
The f_file_stream_close() function is missing some errors.
The file error message printer is missing several error messages.
There is also some cleanup is needed in the file error messages (consistency problems, mostly).
Add F_file_overflow, and F_file_underflow for file specific overflow and underflow.
Add missing F_file_descriptor_not.
Remove F_file_allocation and F_file_deallocation, only the generalized F_memory and F_memory_not are used now.
Kevin Day [Sat, 17 Apr 2021 16:36:17 +0000 (11:36 -0500)]
Cleanup: relocate fl_color code to f_color and remove fl_color.
Ever since f_string became a core/required/special project where all level_0 could depend on it, fl_color no longer needed to be at level_1.
Relocate fl_color into f_color, removing the fl_color project entirely.
Update all dependencies.
This exposed some missing dependencies in fll_program that fl_color is secretly handling.
Fix that as well.
Kevin Day [Sat, 17 Apr 2021 05:41:11 +0000 (00:41 -0500)]
Feature: controller program must support "with full_path".
This is necessary to accomodate fickle programs like SSHD where the full path in argument[0] is required.
This implements a general feature called "with" which is provided to add flags on a per Rule Type basis.
These flags will tweak the Rule Type is some manner.
Only one flag is suppoted at this time: "full_path".
The "full_path" provides the necessary functionality to make SSHD happy.
Kevin Day [Sat, 17 Apr 2021 05:34:34 +0000 (00:34 -0500)]
Update: redesign fl_execute_parameter_option_path in fll_execute.
The previous design of fl_execute_parameter_option_path seemed pointless because it could be detected if a slash is in the progam name.
Recent changes have utilized the slash in the path to do just that.
While working with the controller program the SSHD program revealed that some programs are fickle about what is in their argument[0].
SSHD wants the full path and as such it needs to be provided.
This makes sense as the normal behavior of most programs when started with a full path general expect a full path in argument[0].
The fl_execute_parameter_option_path is redesigned to instead provide a full path for program and for argument[0].
Kevin Day [Sat, 17 Apr 2021 04:00:00 +0000 (23:00 -0500)]
Bugfix: fll_execute does not execute full path.
When passed a full path to a program (rather than depending on detecting in from just a program name) the program does not execute.
There are several logic flaws and mistakes.
- The last_slash should have "+1" to avoid including the slash itself.
- When environment is cleared, it need to potentially use "program" or "arguments.array[0].string" if a slash already exists in the provided name.
- The final NULL at the end of the program_path string is missing.
- The "program" or "arguments.array[0].string" should be used in general instead of always the "program" only.
- The fixated_is is being used incorrectly in private_fll_execute_path_arguments_fixate (and the documentation is incorrect).
I suspect that these functions are messy due to changes in design that were not fully updated (including the appropriate documentation).
Kevin Day [Fri, 16 Apr 2021 23:48:04 +0000 (18:48 -0500)]
Bugfix: properly configure example.
The reason why controller is attempting to execute "/var/run/sshd.pid" is not because it is incorrectly attempting to process the "use" as a start.
Instead, it is because it is properly attempting to do so because it is being told to.
Oops! This is just a simple misconfiguration and not a bug in the code.
A bug in the configuration.
Kevin Day [Fri, 16 Apr 2021 04:20:22 +0000 (23:20 -0500)]
Progress: controller program, begin working on pid file related executions.
It occurred to me that I could quickly create a process with a PID file using a script.
I then realized that "service" only applies to binaries and not scripts.
Add a new type called "utility" that is identical to "service" in purpose except that it processes scripts.
Begin implementing the PID file related code.
It seems there are a few things to address, such as proper test output display.
For example, I am seeing "Simulating execution of '/var/run/sshd.pid' with the arguments: '' from 'SSH Service'.".
That "/var/run/sshd.pid" should instead be "/usr/sbin/sshd".
Creating or checking existence of the PID files is not yet written.
The behavior of after a process forks is not yet written either.
An error needs to be printed and F_failure (with error bit set) should be returned.
The "success = F_failure" should probably have error bit set.
Add new rules and entries for testing this (to be implemented) functionality.
Update the documentation.
Some of the documentation is outdated and as a result, wrong.
Kevin Day [Thu, 15 Apr 2021 02:52:47 +0000 (21:52 -0500)]
Update: implement read lock handlings support.
There are some cases where I am able to figure out a way to make the logic continue on on failure and handle the case of read lock failure.
There are other cases where I am not yet sure how to handle.
Expect more changes in the future to address ability to continue onward on lock failure.
Some functions now return F_lock (with error bit) to designate that the lock failed.
In these cases, it is for functions that require the caller to have a read lock (such as process->lock) locked before starting.
When such functions return the caller now has a way of knowing that the read lock is no longer held.
Kevin Day [Wed, 14 Apr 2021 22:44:13 +0000 (17:44 -0500)]
Update: handle write lock failures, begin adding support for handling read lock failures.
Get the response on write lock failure.
Present an error message.
Return the error status.
Increase the cancellation timeouts from 0.06 seconds to 0.6 seconds, making it less aggresive.
This results in a 90 second max timeout, which gives more problematic exists a lot more time to cleanly exit.
Begin adding support for getting and handing read lock failures.
Read locks attempts will be in a loop that checks main thread enabled as well.
The timeout is longer than write locks to reduce the CPU overhead as there will be a lot of read locks.
Follow up work will utilize this read lock status handling.
Remove the additional thread enabled check that follows a write lock.
The write lock already checks if the main thread is enabled.