Merge lp:~xnox/ubuntu/trusty/plymouth/fsck-details into lp:ubuntu/trusty/plymouth

Proposed by Dimitri John Ledkov
Status: Merged
Merged at revision: 1463
Proposed branch: lp:~xnox/ubuntu/trusty/plymouth/fsck-details
Merge into: lp:ubuntu/trusty/plymouth
Diff against target: 585 lines (+529/-0)
6 files modified
.pc/applied-patches (+1/-0)
.pc/details-update-status.patch/src/plugins/splash/details/plugin.c (+468/-0)
debian/changelog (+7/-0)
debian/patches/details-update-status.patch (+36/-0)
debian/patches/series (+1/-0)
src/plugins/splash/details/plugin.c (+16/-0)
To merge this branch: bzr merge lp:~xnox/ubuntu/trusty/plymouth/fsck-details
Reviewer Review Type Date Requested Status
Upstart Reviewers Pending
Ubuntu branches Pending
Review via email: mp+197312@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Print out fsck messages in plymouth details plugin, in the form of:
fsck:/:17%

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.pc/applied-patches'
--- .pc/applied-patches 2013-06-28 22:58:24 +0000
+++ .pc/applied-patches 2013-12-02 05:06:37 +0000
@@ -12,3 +12,4 @@
12Fix-missing-prototype-of-ply_get_timestamp.patch12Fix-missing-prototype-of-ply_get_timestamp.patch
13Miscellaneous-fixes-for-compiler-warnings.patch13Miscellaneous-fixes-for-compiler-warnings.patch
14autoreconf.patch14autoreconf.patch
15details-update-status.patch
1516
=== added directory '.pc/details-update-status.patch'
=== added directory '.pc/details-update-status.patch/src'
=== added directory '.pc/details-update-status.patch/src/plugins'
=== added directory '.pc/details-update-status.patch/src/plugins/splash'
=== added directory '.pc/details-update-status.patch/src/plugins/splash/details'
=== added file '.pc/details-update-status.patch/src/plugins/splash/details/plugin.c'
--- .pc/details-update-status.patch/src/plugins/splash/details/plugin.c 1970-01-01 00:00:00 +0000
+++ .pc/details-update-status.patch/src/plugins/splash/details/plugin.c 2013-12-02 05:06:37 +0000
@@ -0,0 +1,468 @@
1/* details.c - boot splash plugin
2 *
3 * Copyright (C) 2008 Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
19 *
20 * Written by: Ray Strode <rstrode@redhat.com>
21 */
22#include "config.h"
23
24#include <assert.h>
25#include <errno.h>
26#include <fcntl.h>
27#include <math.h>
28#include <signal.h>
29#include <stdbool.h>
30#include <stdio.h>
31#include <stdint.h>
32#include <stdlib.h>
33#include <string.h>
34#include <sys/ioctl.h>
35#include <sys/stat.h>
36#include <sys/time.h>
37#include <sys/types.h>
38#include <termios.h>
39#include <unistd.h>
40#include <wchar.h>
41#include <values.h>
42
43#include "ply-boot-splash-plugin.h"
44#include "ply-buffer.h"
45#include "ply-event-loop.h"
46#include "ply-key-file.h"
47#include "ply-list.h"
48#include "ply-logger.h"
49#include "ply-text-display.h"
50#include "ply-trigger.h"
51#include "ply-utils.h"
52
53#include <linux/kd.h>
54
55#define CLEAR_LINE_SEQUENCE "\033[2K\r"
56
57typedef enum {
58 PLY_BOOT_SPLASH_DISPLAY_NORMAL,
59 PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY,
60 PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY
61} ply_boot_splash_display_type_t;
62
63typedef struct
64{
65 ply_boot_splash_plugin_t *plugin;
66 ply_text_display_t *display;
67} view_t;
68
69ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
70static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
71
72struct _ply_boot_splash_plugin
73{
74 ply_event_loop_t *loop;
75 ply_boot_splash_mode_t mode;
76 ply_list_t *views;
77 ply_boot_splash_display_type_t state;
78 ply_list_t *messages;
79
80};
81
82static view_t *
83view_new (ply_boot_splash_plugin_t *plugin,
84 ply_text_display_t *display)
85{
86 view_t *view;
87
88 view = calloc (1, sizeof (view_t));
89 view->plugin = plugin;
90 view->display = display;
91
92 return view;
93}
94
95static void
96view_free (view_t *view)
97{
98 free (view);
99}
100
101static void
102free_views (ply_boot_splash_plugin_t *plugin)
103{
104 ply_list_node_t *node;
105
106 node = ply_list_get_first_node (plugin->views);
107
108 while (node != NULL)
109 {
110 ply_list_node_t *next_node;
111 view_t *view;
112
113 view = ply_list_node_get_data (node);
114 next_node = ply_list_get_next_node (plugin->views, node);
115
116 view_free (view);
117 ply_list_remove_node (plugin->views, node);
118
119 node = next_node;
120 }
121
122 ply_list_free (plugin->views);
123 plugin->views = NULL;
124}
125
126static void
127free_messages (ply_boot_splash_plugin_t *plugin)
128{
129 ply_list_node_t *node;
130
131 node = ply_list_get_first_node (plugin->messages);
132
133 while (node != NULL)
134 {
135 ply_list_node_t *next_node;
136 char *message;
137
138 message = ply_list_node_get_data (node);
139 next_node = ply_list_get_next_node (plugin->messages, node);
140
141 free (message);
142 ply_list_remove_node (plugin->messages, node);
143
144 node = next_node;
145 }
146
147 ply_list_free (plugin->messages);
148 plugin->messages = NULL;
149}
150
151static ply_boot_splash_plugin_t *
152create_plugin (ply_key_file_t *key_file)
153{
154 ply_boot_splash_plugin_t *plugin;
155
156 ply_trace ("creating plugin");
157
158 plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
159 plugin->views = ply_list_new ();
160 plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
161 plugin->messages = ply_list_new ();
162 return plugin;
163}
164
165static void
166destroy_plugin (ply_boot_splash_plugin_t *plugin)
167{
168 ply_trace ("destroying plugin");
169
170 if (plugin == NULL)
171 return;
172
173 if (plugin->loop != NULL)
174 {
175 ply_event_loop_stop_watching_for_exit (plugin->loop, (ply_event_loop_exit_handler_t)
176 detach_from_event_loop,
177 plugin);
178 detach_from_event_loop (plugin);
179 }
180
181 free_messages (plugin);
182 free_views (plugin);
183
184 free (plugin);
185}
186
187static void
188detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
189{
190 plugin->loop = NULL;
191
192 ply_trace ("detaching from event loop");
193}
194
195static void
196view_write (view_t *view,
197 const char *text,
198 size_t number_of_bytes)
199{
200 ply_terminal_t *terminal;
201
202 terminal = ply_text_display_get_terminal (view->display);
203 ply_terminal_write (terminal, "%.*s", (int) number_of_bytes, text);
204}
205
206static void
207write_on_views (ply_boot_splash_plugin_t *plugin,
208 const char *text,
209 size_t number_of_bytes)
210{
211 ply_list_node_t *node;
212
213 if (number_of_bytes == 0)
214 return;
215
216 node = ply_list_get_first_node (plugin->views);
217
218 while (node != NULL)
219 {
220 ply_list_node_t *next_node;
221 view_t *view;
222
223 view = ply_list_node_get_data (node);
224 next_node = ply_list_get_next_node (plugin->views, node);
225
226 view_write (view, text, number_of_bytes);
227
228 node = next_node;
229 }
230
231}
232
233static void
234add_text_display (ply_boot_splash_plugin_t *plugin,
235 ply_text_display_t *display)
236{
237 view_t *view;
238 ply_terminal_t *terminal;
239
240 view = view_new (plugin, display);
241
242 terminal = ply_text_display_get_terminal (view->display);
243 if (ply_terminal_open (terminal))
244 ply_terminal_activate_vt (terminal);
245
246 ply_list_append_data (plugin->views, view);
247}
248
249static void
250remove_text_display (ply_boot_splash_plugin_t *plugin,
251 ply_text_display_t *display)
252{
253 ply_list_node_t *node;
254
255 node = ply_list_get_first_node (plugin->views);
256 while (node != NULL)
257 {
258 view_t *view;
259 ply_list_node_t *next_node;
260
261 view = ply_list_node_get_data (node);
262 next_node = ply_list_get_next_node (plugin->views, node);
263
264 if (view->display == display)
265 {
266 ply_list_remove_node (plugin->views, node);
267 return;
268 }
269
270 node = next_node;
271 }
272}
273
274static bool
275show_splash_screen (ply_boot_splash_plugin_t *plugin,
276 ply_event_loop_t *loop,
277 ply_buffer_t *boot_buffer,
278 ply_boot_splash_mode_t mode)
279{
280 size_t size;
281
282 assert (plugin != NULL);
283
284 plugin->loop = loop;
285 plugin->mode = mode;
286
287 ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
288 detach_from_event_loop,
289 plugin);
290
291 if (boot_buffer)
292 {
293 size = ply_buffer_get_size (boot_buffer);
294
295 write_on_views (plugin, ply_buffer_get_bytes (boot_buffer), size);
296 }
297
298 return true;
299}
300
301static void
302update_status (ply_boot_splash_plugin_t *plugin,
303 const char *status)
304{
305 assert (plugin != NULL);
306
307 ply_trace ("status update");
308}
309
310static void
311on_boot_output (ply_boot_splash_plugin_t *plugin,
312 const char *output,
313 size_t size)
314{
315 ply_trace ("writing '%s' to all views (%d bytes)",
316 output, (int) size);
317 write_on_views (plugin, output, size);
318}
319
320static void
321hide_splash_screen (ply_boot_splash_plugin_t *plugin,
322 ply_event_loop_t *loop)
323{
324 assert (plugin != NULL);
325
326 ply_trace ("hiding splash screen");
327
328 ply_event_loop_stop_watching_for_exit (plugin->loop,
329 (ply_event_loop_exit_handler_t)
330 detach_from_event_loop,
331 plugin);
332 detach_from_event_loop (plugin);
333}
334
335static void
336display_normal (ply_boot_splash_plugin_t *plugin)
337{
338 ply_list_node_t *node;
339
340 if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
341 write_on_views (plugin, "\r\n", strlen ("\r\n"));
342
343 plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
344
345 node = ply_list_get_first_node (plugin->messages);
346 while (node != NULL)
347 {
348 const char *message;
349 ply_list_node_t *next_node;
350
351 message = ply_list_node_get_data (node);
352 next_node = ply_list_get_next_node (plugin->messages, node);
353
354 write_on_views (plugin, message, strlen (message));
355 write_on_views (plugin, "\r\n", strlen ("\r\n"));
356
357 ply_list_remove_node (plugin->messages, node);
358 node = next_node;
359 }
360}
361
362/* @shorten_prompt:
363 *
364 * Points prompt to the character immediately after the
365 * last '\n' in prompt
366 */
367static void shorten_prompt(const char ** prompt)
368{
369 int last_nl=-1, i=0;
370 const char * str = *prompt;
371 for(i=0; str[i] != '\0'; i++) {
372 if(str[i] == '\n') {
373 last_nl = i;
374 }
375 }
376 if (last_nl >= 0) {
377 if((str[last_nl] == '\n') && (last_nl < i)){
378 *prompt = &str[last_nl + 1];
379 }
380 }
381}
382
383static void
384display_password (ply_boot_splash_plugin_t *plugin,
385 const char *prompt,
386 int bullets)
387{
388 int i;
389 if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
390 write_on_views (plugin, "\r\n", strlen ("\r\n"));
391 else
392 write_on_views (plugin,
393 CLEAR_LINE_SEQUENCE,
394 strlen (CLEAR_LINE_SEQUENCE));
395 plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
396
397 if (prompt) {
398 if (bullets > 0)
399 shorten_prompt(&prompt);
400 write_on_views (plugin,
401 prompt,
402 strlen (prompt));
403 }
404 else
405 write_on_views (plugin,
406 "Password:",
407 strlen ("Password:"));
408
409 for (i = 0; i < bullets; i++)
410 write_on_views (plugin, "*", strlen ("*"));
411}
412
413static void
414display_question (ply_boot_splash_plugin_t *plugin,
415 const char *prompt,
416 const char *entry_text)
417{
418 if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY)
419 write_on_views (plugin, "\r\n", strlen ("\r\n"));
420 else
421 write_on_views (plugin,
422 CLEAR_LINE_SEQUENCE,
423 strlen (CLEAR_LINE_SEQUENCE));
424
425 plugin->state = PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY;
426 if (prompt)
427 write_on_views (plugin, prompt, strlen (prompt));
428
429 write_on_views (plugin, ":", strlen (":"));
430 write_on_views (plugin, entry_text, strlen (entry_text));
431}
432
433static void
434display_message (ply_boot_splash_plugin_t *plugin,
435 const char *message)
436{
437 if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
438 {
439 write_on_views (plugin, message, strlen (message));
440 write_on_views (plugin, "\r\n", strlen ("\r\n"));
441 }
442 else
443 ply_list_append_data (plugin->messages, strdup (message));
444}
445
446ply_boot_splash_plugin_interface_t *
447ply_boot_splash_plugin_get_interface (void)
448{
449 static ply_boot_splash_plugin_interface_t plugin_interface =
450 {
451 .create_plugin = create_plugin,
452 .destroy_plugin = destroy_plugin,
453 .add_text_display = add_text_display,
454 .remove_text_display = remove_text_display,
455 .show_splash_screen = show_splash_screen,
456 .update_status = update_status,
457 .on_boot_output = on_boot_output,
458 .hide_splash_screen = hide_splash_screen,
459 .display_normal = display_normal,
460 .display_password = display_password,
461 .display_question = display_question,
462 .display_message = display_message,
463 };
464
465 return &plugin_interface;
466}
467
468/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
0469
=== modified file 'debian/changelog'
--- debian/changelog 2013-11-28 21:05:57 +0000
+++ debian/changelog 2013-12-02 05:06:37 +0000
@@ -1,3 +1,10 @@
1plymouth (0.8.8-0ubuntu11) UNRELEASED; urgency=low
2
3 * Implement update status (U) splash plugin function for details plugin,
4 simply display those updates as text messages. (LP: #540645)
5
6 -- Dmitrijs Ledkovs <xnox@ubuntu.com> Mon, 02 Dec 2013 04:08:09 +0000
7
1plymouth (0.8.8-0ubuntu10) trusty; urgency=low8plymouth (0.8.8-0ubuntu10) trusty; urgency=low
29
3 * Update font dependency from ttf-dejavu-core to fonts-dejavu-core.10 * Update font dependency from ttf-dejavu-core to fonts-dejavu-core.
411
=== added file 'debian/patches/details-update-status.patch'
--- debian/patches/details-update-status.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/details-update-status.patch 2013-12-02 05:06:37 +0000
@@ -0,0 +1,36 @@
1Description: Implement update status (U) splash plugin function for details plugins
2Author: Dmitrijs Ledkovs <xnox@ubuntu.com>
3Bug-Ubuntu: https://bugs.launchpad.net/bugs/540645
4
5--- a/src/plugins/splash/details/plugin.c
6+++ b/src/plugins/splash/details/plugin.c
7@@ -79,6 +79,9 @@
8
9 };
10
11+static void display_message (ply_boot_splash_plugin_t *plugin,
12+ const char *message);
13+
14 static view_t *
15 view_new (ply_boot_splash_plugin_t *plugin,
16 ply_text_display_t *display)
17@@ -305,6 +308,19 @@
18 assert (plugin != NULL);
19
20 ply_trace ("status update");
21+
22+ int progress = 0;
23+
24+ if (! strncmp("fsck:", status, 5)) {
25+ /* Chop localised formatted string */
26+ /* fsck:sda1:50:Checking disk %1$d of %2$d (%3$d%% complete) */
27+ sscanf(status, "fsck:.*:%d:.*", &progress);
28+ char *end = strrchr(status, ':');
29+ strncpy (end, "%\0", 2);
30+ }
31+
32+ if (progress < 100)
33+ display_message (plugin, status);
34 }
35
36 static void
037
=== modified file 'debian/patches/series'
--- debian/patches/series 2013-06-28 22:58:24 +0000
+++ debian/patches/series 2013-12-02 05:06:37 +0000
@@ -12,3 +12,4 @@
12Fix-missing-prototype-of-ply_get_timestamp.patch12Fix-missing-prototype-of-ply_get_timestamp.patch
13Miscellaneous-fixes-for-compiler-warnings.patch13Miscellaneous-fixes-for-compiler-warnings.patch
14autoreconf.patch14autoreconf.patch
15details-update-status.patch
1516
=== modified file 'src/plugins/splash/details/plugin.c'
--- src/plugins/splash/details/plugin.c 2012-04-30 06:03:00 +0000
+++ src/plugins/splash/details/plugin.c 2013-12-02 05:06:37 +0000
@@ -79,6 +79,9 @@
7979
80};80};
8181
82static void display_message (ply_boot_splash_plugin_t *plugin,
83 const char *message);
84
82static view_t *85static view_t *
83view_new (ply_boot_splash_plugin_t *plugin,86view_new (ply_boot_splash_plugin_t *plugin,
84 ply_text_display_t *display)87 ply_text_display_t *display)
@@ -305,6 +308,19 @@
305 assert (plugin != NULL);308 assert (plugin != NULL);
306309
307 ply_trace ("status update");310 ply_trace ("status update");
311
312 int progress = 0;
313
314 if (! strncmp("fsck:", status, 5)) {
315 /* Chop localised formatted string */
316 /* fsck:sda1:50:Checking disk %1$d of %2$d (%3$d%% complete) */
317 sscanf(status, "fsck:.*:%d:.*", &progress);
318 char *end = strrchr(status, ':');
319 strncpy (end, "%\0", 2);
320 }
321
322 if (progress < 100)
323 display_message (plugin, status);
308}324}
309325
310static void326static void

Subscribers

People subscribed via source and target branches