This is a directory path to the sysfs cgroups directory.
It must end in a path separator '/'.
There is existing code that needed to be updated to use the -c/--control.
It was being ignored!
fprintf(output.stream, "%c", f_string_eol_s[0]);
- fll_program_print_help_option(output, context, controller_short_control, controller_long_control, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom control group file path, such as '" controller_path_control "'.");
+ fll_program_print_help_option(output, context, controller_short_control, controller_long_control, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom control group file path, such as '" f_control_group_path_system_prefix f_control_group_path_system_default "'.");
fll_program_print_help_option(output, context, controller_short_daemon, controller_long_daemon, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Run in daemon only mode (do not process the entry).");
fll_program_print_help_option(output, context, controller_short_interruptable, controller_long_interruptable, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Designate that this program can be interrupted.");
fll_program_print_help_option(output, context, controller_short_pid, controller_long_pid, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Specify a custom pid file path, such as '" controller_path_pid controller_string_default controller_path_suffix "'.");
fll_error_print(data->error, F_status_set_fine(status), "fll_path_canonical", F_true);
}
}
+ else {
+ status = f_string_append_assure(f_path_separator, 1, &setting.path_control);
+
+ if (F_status_is_error(status)) {
+ if (data->error.verbosity != f_console_verbosity_quiet) {
+ fll_error_print(data->error, F_status_set_fine(status), "f_string_append_assure", F_true);
+ }
+ }
+ else {
+ status = f_string_dynamic_terminate_after(&setting.path_control);
+
+ if (F_status_is_error(status)) {
+ if (data->error.verbosity != f_console_verbosity_quiet) {
+ fll_error_print(data->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
+ }
+ }
+ }
+ }
}
else {
if (data->warning.verbosity == f_console_verbosity_debug) {
// a control file path is required.
if (!setting.path_control.used) {
- status = f_string_append(controller_path_control, controller_path_control_length, &setting.path_control);
+ status = f_string_append_nulless(f_control_group_path_system_prefix, f_control_group_path_system_prefix_length, &setting.path_control);
+
+ if (F_status_is_error_not(status)) {
+ status = f_string_append_nulless(f_control_group_path_system_default, f_control_group_path_system_default_length, &setting.path_control);
+ }
if (F_status_is_error(status)) {
if (data->error.verbosity != f_console_verbosity_quiet) {
- fll_error_print(data->error, F_status_set_fine(status), "f_string_append", F_true);
+ fll_error_print(data->error, F_status_set_fine(status), "f_string_append_nulless", F_true);
+ }
+ }
+ else {
+ status = f_string_append_assure(f_path_separator, 1, &setting.path_control);
+
+ if (F_status_is_error(status)) {
+ if (data->error.verbosity != f_console_verbosity_quiet) {
+ fll_error_print(data->error, F_status_set_fine(status), "f_string_append_assure", F_true);
+ }
+ }
+ else {
+ status = f_string_dynamic_terminate_after(&setting.path_control);
+
+ if (F_status_is_error(status)) {
+ if (data->error.verbosity != f_console_verbosity_quiet) {
+ fll_error_print(data->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true);
+ }
+ }
}
}
}
#define controller_default_program_script "bash"
- #define controller_path_control "/sys/fs/cgroup/unified"
#define controller_path_pid "/var/run/controller/controller-"
#define controller_path_settings "/etc/controller"
#define controller_path_suffix ".pid"
- #define controller_path_control_length 22
#define controller_path_pid_length 31
#define controller_path_settings_length 15
#define controller_path_suffix_length 4
}
#endif // _di_controller_entry_items_delete_simple_
+#ifndef _di_controller_error_file_print_
+ void controller_error_file_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type, controller_thread_t *thread) {
+
+ if (print.verbosity != f_console_verbosity_quiet) {
+ f_thread_mutex_lock(&thread->lock.print);
+
+ fll_error_file_print(print, status, function, fallback, name, operation, type);
+
+ controller_print_unlock_flush(print.to.stream, &thread->lock.print);
+ }
+ }
+#endif // _di_controller_error_file_print_
+
#ifndef _di_controller_error_print_
void controller_error_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, controller_thread_t *thread) {
#endif // _di_controller_entry_items_delete_simple_
/**
+ * Print the file error, locking the print mutex during the print.
+ *
+ * @param print
+ * Designates how printing is to be performed.
+ * @param status
+ * The status code to process.
+ * Make sure this has F_status_set_fine() called if the status code has any error or warning bits.
+ * @param function
+ * The name of the function where the error happened.
+ * Set to 0 to disable.
+ * @param fallback
+ * Set to F_true to print the fallback error message for unknown errors.
+ * @param name
+ * The name of the file or directory.
+ * @param operation
+ * The operation that fails, such as 'create' or 'access'.
+ * @param type
+ * A valid file type code from the fll_error_file_type enum.
+ * @param thread
+ * The thread data.
+ *
+ * @see fll_error_file_print()
+ */
+#ifndef _di_controller_error_file_print_
+ extern void controller_error_file_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, const f_string_t name, const f_string_t operation, const uint8_t type, controller_thread_t *thread) f_gcc_attribute_visibility_internal;
+#endif // _di_controller_error_file_print_
+
+
+/**
* Print the error, locking the print mutex during the print.
*
* @param print
f_status_t controller_get_id_user(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t *cache, uid_t *id) {
f_number_unsigned_t number = 0;
- // @todo fix argument ordering in fl_conversion_string_to_number_unsigned().
f_status_t status = fl_conversion_string_to_number_unsigned(buffer.string, range, &number);
if (F_status_is_error(status)) {
f_status_t controller_get_id_group(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t *cache, gid_t *id) {
f_number_unsigned_t number = 0;
- // @todo fix argument ordering in fl_conversion_string_to_number_unsigned().
f_status_t status = fl_conversion_string_to_number_unsigned(buffer.string, range, &number);
if (F_status_is_error(status)) {
status = fll_control_group_prepare(process->rule.control_group);
if (F_status_is_error(status)) {
- controller_error_print(main.data->error, F_status_set_fine(status), "fll_control_group_prepare", F_true, main.thread);
+ controller_error_file_print(main.data->error, F_status_set_fine(status), "fll_control_group_prepare", F_true, process->rule.control_group.path.string, "prepare control groups for", fll_error_file_type_directory, main.thread);
return status;
}
rule->control_group.path.used = 0;
- // @todo path prefix needs to be configurable via a parameter.
- status = f_string_append(f_control_group_path_system_prefix, f_control_group_path_system_prefix_length, &rule->control_group.path);
-
- if (F_status_is_error_not(status)) {
- status = f_string_append(f_control_group_path_system_default, f_control_group_path_system_default_length, &rule->control_group.path);
- }
+ status = f_string_dynamic_append(main.setting->path_control, &rule->control_group.path);
if (F_status_is_error(status)) {
- controller_rule_error_print(main.data->error, cache->action, F_status_set_fine(status), "f_string_append", F_true, F_false, main.thread);
+ controller_rule_error_print(main.data->error, cache->action, F_status_set_fine(status), "f_string_dynamic_append", F_true, F_false, main.thread);
}
else {
rule->control_group.groups.used = 0;