Cliff Zhao
3a49828aeb
- Update to version 0.9.5~git20220803.52b0494: src: Run through uncrustify. scripts: Diff less. scripts: Update uncrustify config. src: Drop vim: lines. ply-utils: Drop linux/fs.h include. scripts: Add -B to interdiff in check-format. - Rebase plymouth-log-on-default.patch; - Rebase plymouth-screen-twice-scale-on-160DPI-higher.patch; OBS-URL: https://build.opensuse.org/request/show/993084 OBS-URL: https://build.opensuse.org/package/show/Base:System/plymouth?expand=0&rev=339
239 lines
8.6 KiB
Diff
239 lines
8.6 KiB
Diff
diff -Nura plymouth-0.9.5~git20220801.eb1b893/src/libply/ply-buffer.c plymouth-0.9.5~git20220801.eb1b893_new/src/libply/ply-buffer.c
|
|
--- plymouth-0.9.5~git20220801.eb1b893/src/libply/ply-buffer.c 2022-04-15 16:39:24.000000000 +0800
|
|
+++ plymouth-0.9.5~git20220801.eb1b893_new/src/libply/ply-buffer.c 2022-08-04 16:27:35.810694440 +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)
|
|
@@ -205,6 +223,38 @@
|
|
}
|
|
|
|
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-0.9.5~git20220801.eb1b893/src/libply/ply-buffer.h plymouth-0.9.5~git20220801.eb1b893_new/src/libply/ply-buffer.h
|
|
--- plymouth-0.9.5~git20220801.eb1b893/src/libply/ply-buffer.h 2022-04-15 16:39:24.000000000 +0800
|
|
+++ plymouth-0.9.5~git20220801.eb1b893_new/src/libply/ply-buffer.h 2022-08-04 16:27:35.810694440 +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-0.9.5~git20220801.eb1b893/src/main.c plymouth-0.9.5~git20220801.eb1b893_new/src/main.c
|
|
--- plymouth-0.9.5~git20220801.eb1b893/src/main.c 2022-08-02 21:28:28.000000000 +0800
|
|
+++ plymouth-0.9.5~git20220801.eb1b893_new/src/main.c 2022-08-04 17:37:22.768631505 +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 ());
|
|
}
|
|
|
|
static void
|
|
@@ -1853,77 +1852,42 @@
|
|
state->is_attached = false;
|
|
}
|
|
|
|
-static void
|
|
-check_verbosity (state_t *state)
|
|
+static void initialize_debug (state_t *state)
|
|
{
|
|
- char *stream;
|
|
-
|
|
- ply_trace ("checking if tracing should be enabled");
|
|
-
|
|
- 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;
|
|
-
|
|
- ply_trace ("redirecting debug output to %s", device);
|
|
-
|
|
- if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
|
|
- file = strdup (device);
|
|
- else
|
|
- asprintf (&file, "/dev/%s", device);
|
|
+ if (!ply_is_tracing ())
|
|
+ ply_toggle_tracing ();
|
|
|
|
- fd = open (file, O_RDWR | O_APPEND);
|
|
+ if (debug_buffer == NULL)
|
|
+ debug_buffer = ply_buffer_new ();
|
|
|
|
- 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);
|
|
-
|
|
- free (file);
|
|
- }
|
|
- } else {
|
|
- ply_trace ("tracing shouldn't be enabled!");
|
|
- }
|
|
-
|
|
- 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");
|
|
- }
|
|
+ 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");
|
|
+ }
|
|
|
|
- ply_logger_add_filter (ply_logger_get_error_default (),
|
|
- (ply_logger_filter_handler_t)
|
|
- on_error_message,
|
|
- debug_buffer);
|
|
- }
|
|
+ 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
|
|
@@ -2007,7 +1971,7 @@
|
|
}
|
|
}
|
|
|
|
- check_verbosity (state);
|
|
+ initialize_debug (state);
|
|
check_logging (state);
|
|
|
|
ply_trace ("source built on %s", __DATE__);
|
|
@@ -2033,7 +1997,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 +2120,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;
|