Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Base:System
plymouth
plymouth-log-on-default.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File plymouth-log-on-default.patch of Package plymouth
diff -Nura plymouth-22.02.122+180.b1d5aa9/src/libply/ply-buffer.c plymouth-22.02.122+180.b1d5aa9_new/src/libply/ply-buffer.c --- plymouth-22.02.122+180.b1d5aa9/src/libply/ply-buffer.c 2022-11-28 18:33:06.000000000 +0800 +++ plymouth-22.02.122+180.b1d5aa9_new/src/libply/ply-buffer.c 2023-07-12 22:25:31.095721303 +0800 @@ -46,6 +46,10 @@ #define PLY_BUFFER_MAX_BUFFER_CAPACITY (255 * 4096) #endif +#ifndef PLY_BUFFER_MAX_LOG_BUFFER_CAPACITY +#define PLY_BUFFER_MAX_LOG_BUFFER_CAPACITY (1024 * 4096) +#endif + struct _ply_buffer { char *data; @@ -67,6 +71,20 @@ return true; } +static bool +ply_buffer_increase_log_capacity (ply_buffer_t *buffer) +{ + assert (buffer != NULL); + + if ((buffer->capacity * 2) > PLY_BUFFER_MAX_LOG_BUFFER_CAPACITY) + return false; + + buffer->capacity *= 2; + + buffer->data = realloc (buffer->data, buffer->capacity); + return true; +} + void ply_buffer_remove_bytes (ply_buffer_t *buffer, size_t bytes_to_remove) @@ -206,6 +224,37 @@ buffer->data[buffer->size] = '\0'; } +void ply_buffer_append_log_bytes (ply_buffer_t *buffer, + const void *bytes_in, + size_t length) +{ + assert (buffer != NULL); + assert (bytes_in != NULL); + assert (length != 0); + + const uint8_t *bytes = bytes_in; + + if (length > PLY_BUFFER_MAX_BUFFER_CAPACITY) + { + bytes += length - (PLY_BUFFER_MAX_BUFFER_CAPACITY - 1); + length = (PLY_BUFFER_MAX_BUFFER_CAPACITY - 1); + } + + while ((buffer->size + length) >= buffer->capacity) + { + if (!ply_buffer_increase_log_capacity (buffer)) + ply_buffer_remove_bytes (buffer, length); + } + + assert (buffer->size + length < buffer->capacity); + + memcpy (buffer->data + buffer->size, + bytes, length); + + buffer->size += length; + buffer->data[buffer->size] = '\0'; +} + void ply_buffer_append_from_fd (ply_buffer_t *buffer, int fd) diff -Nura plymouth-22.02.122+180.b1d5aa9/src/libply/ply-buffer.h plymouth-22.02.122+180.b1d5aa9_new/src/libply/ply-buffer.h --- plymouth-22.02.122+180.b1d5aa9/src/libply/ply-buffer.h 2022-11-27 00:45:52.000000000 +0800 +++ plymouth-22.02.122+180.b1d5aa9_new/src/libply/ply-buffer.h 2023-07-12 22:20:11.765612637 +0800 @@ -35,6 +35,10 @@ const void *bytes, size_t number_of_bytes); +void ply_buffer_append_log_bytes (ply_buffer_t *buffer, + const void *bytes, + size_t length); + void ply_buffer_append_from_fd (ply_buffer_t *buffer, int fd); #define ply_buffer_append(buffer, format, args ...) \ diff -Nura plymouth-22.02.122+180.b1d5aa9/src/main.c plymouth-22.02.122+180.b1d5aa9_new/src/main.c --- plymouth-22.02.122+180.b1d5aa9/src/main.c 2023-06-08 10:49:58.000000000 +0800 +++ plymouth-22.02.122+180.b1d5aa9_new/src/main.c 2023-07-12 22:38:56.846042006 +0800 @@ -1283,8 +1283,7 @@ } /* do not let any tty opened where we could write after deactivate */ - if (ply_kernel_command_line_has_argument ("plymouth.debug")) - ply_logger_close_file (ply_logger_get_error_default ()); + ply_logger_close_file (ply_logger_get_error_default ()); } static void @@ -1916,6 +1915,7 @@ state->is_attached = false; } +#if 0 static void check_verbosity (state_t *state) { @@ -1988,6 +1988,45 @@ debug_buffer); } } +#endif + +static void initialize_debug (state_t *state) +{ + if (!ply_is_tracing ()) + ply_toggle_tracing (); + + if (debug_buffer == NULL) + debug_buffer = ply_buffer_new (); + + char *stream = ply_kernel_command_line_get_key_value ("plymouth.debug=stream:"); + if (stream != NULL) + { + int fd = open (stream, O_RDWR | O_NOCTTY | O_CREAT, 0600); + if (fd < 0) + ply_trace ("could not stream output to %s: %m", stream); + else + ply_logger_set_output_fd (ply_logger_get_error_default (), fd); + free (stream); + } + + if (!debug_buffer_path) + debug_buffer_path = ply_kernel_command_line_get_key_value ("plymouth.debug=file:"); + + if (debug_buffer_path == NULL) + { + if (state->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN || state->mode == PLY_BOOT_SPLASH_MODE_REBOOT) + debug_buffer_path = strdup (PLYMOUTH_LOG_DIRECTORY "/plymouth-shutdown-debug.log"); + else + debug_buffer_path = strdup (PLYMOUTH_LOG_DIRECTORY "/plymouth-debug.log"); + } + + if (debug_buffer != NULL) + { + ply_logger_add_filter (ply_logger_get_error_default (), + (ply_logger_filter_handler_t) on_error_message, + debug_buffer); + } +} static void check_logging (state_t *state) @@ -2074,8 +2113,10 @@ ply_trace ("going to go with '%s'", state->default_tty); } } - +#if 0 check_verbosity (state); +#endif + initialize_debug (state); check_logging (state); ply_trace ("source built on %s", __DATE__); @@ -2101,7 +2142,10 @@ const void *bytes, size_t number_of_bytes) { +#if 0 ply_buffer_append_bytes (debug_buffer, bytes, number_of_bytes); +#endif + ply_buffer_append_log_bytes (debug_buffer, bytes, number_of_bytes); } static void @@ -2224,7 +2268,7 @@ bool should_help = false; bool no_boot_log = false; bool no_daemon = false; - bool debug = false; + bool debug = true; bool ignore_serial_consoles = false; bool graphical_boot = false; bool attach_to_session;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor