plymouth/plymouth-log-on-default.patch
Cliff Zhao 1799fdbb0d Accepting request 975514 from home:qzhao:branches:Base:System
1. Add plymouth-log-on-default.patch: Enable plymouth log by default, help to resolve random appear problems (bsc#1193736). 2. Pick back patch information for label-ft.

OBS-URL: https://build.opensuse.org/request/show/975514
OBS-URL: https://build.opensuse.org/package/show/Base:System/plymouth?expand=0&rev=316
2022-05-07 06:16:07 +00:00

225 lines
8.6 KiB
Diff

diff -Nura plymouth-0.9.5~git20220412.e960111/src/libply/ply-buffer.c plymouth-0.9.5~git20220412.e960111_new/src/libply/ply-buffer.c
--- plymouth-0.9.5~git20220412.e960111/src/libply/ply-buffer.c 2022-04-15 16:39:24.000000000 +0800
+++ plymouth-0.9.5~git20220412.e960111_new/src/libply/ply-buffer.c 2022-05-07 12:10:27.891589631 +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)
@@ -195,6 +213,36 @@
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_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,
diff -Nura plymouth-0.9.5~git20220412.e960111/src/libply/ply-buffer.h plymouth-0.9.5~git20220412.e960111_new/src/libply/ply-buffer.h
--- plymouth-0.9.5~git20220412.e960111/src/libply/ply-buffer.h 2022-04-15 16:39:24.000000000 +0800
+++ plymouth-0.9.5~git20220412.e960111_new/src/libply/ply-buffer.h 2022-05-07 12:10:27.892589638 +0800
@@ -34,7 +34,10 @@
void ply_buffer_append_bytes (ply_buffer_t *buffer,
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-0.9.5~git20220412.e960111/src/main.c plymouth-0.9.5~git20220412.e960111_new/src/main.c
--- plymouth-0.9.5~git20220412.e960111/src/main.c 2022-04-15 16:39:24.000000000 +0800
+++ plymouth-0.9.5~git20220412.e960111_new/src/main.c 2022-05-07 12:10:27.892589638 +0800
@@ -1225,8 +1225,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 ());
}
@@ -1854,71 +1853,39 @@
}
static void
-check_verbosity (state_t *state)
+initialize_debug (state_t *state)
{
- char *stream;
- ply_trace ("checking if tracing should be enabled");
+ if (!ply_is_tracing ())
+ ply_toggle_tracing ();
- if (!debug_buffer_path)
- debug_buffer_path = ply_kernel_command_line_get_key_value ("plymouth.debug=file:");
-
- stream = ply_kernel_command_line_get_key_value ("plymouth.debug=stream:");
- if (stream != NULL || debug_buffer_path != NULL ||
- ply_kernel_command_line_has_argument ("plymouth.debug")) {
- int fd;
-
- ply_trace ("tracing should be enabled!");
- if (!ply_is_tracing ())
- ply_toggle_tracing ();
-
- if (debug_buffer == NULL)
- debug_buffer = ply_buffer_new ();
-
- if (stream != NULL) {
- ply_trace ("streaming debug output to %s instead of screen", stream);
- 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);
- } else {
- const char *device;
- char *file;
-
- device = state->default_tty;
+ if (debug_buffer == NULL)
+ debug_buffer = ply_buffer_new ();
- ply_trace ("redirecting debug output to %s", device);
-
- if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
- file = strdup (device);
- else
- asprintf (&file, "/dev/%s", device);
-
- fd = open (file, O_RDWR | O_APPEND);
+ 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 (fd < 0)
- ply_trace ("could not redirected debug output to %s: %m", device);
- else
- ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
+ if (!debug_buffer_path)
+ debug_buffer_path = ply_kernel_command_line_get_key_value ("plymouth.debug=file:");
- free (file);
- }
- } else {
- ply_trace ("tracing shouldn't be enabled!");
+ 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) {
- 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,
@@ -2007,7 +1974,7 @@
}
}
- check_verbosity (state);
+ initialize_debug (state);
check_logging (state);
ply_trace ("source built on %s", __DATE__);
@@ -2033,7 +2000,7 @@
const void *bytes,
size_t number_of_bytes)
{
- ply_buffer_append_bytes (debug_buffer, bytes, number_of_bytes);
+ ply_buffer_append_log_bytes (debug_buffer, bytes, number_of_bytes);
}
static void
@@ -2156,7 +2123,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 attach_to_session;
ply_daemon_handle_t *daemon_handle = NULL;