Merge lp:~xnox/ubuntu/trusty/plymouth/fsck-details into lp:ubuntu/trusty/plymouth
- Trusty (14.04)
- fsck-details
- Merge into trusty
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Upstart Reviewers | Pending | ||
Ubuntu branches | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message

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