[systemd-devel] How to implement fsck progress report with systemd and plymouth?

fykcee1 at gmail.com fykcee1 at gmail.com
Sun Jun 19 23:50:18 PDT 2011


Hi all,
2011/4/27 fykcee1 at gmail.com <fykcee1 at gmail.com>
>
> Hi,
>
> 2011/4/27 Lennart Poettering <lennart at poettering.net>:
> > I would suggest to leave the parsing of the fsck -C output to fsckd, as
> > well as the integration of multiple of these streams. fsckd would then
> > only pass one stream of progress bar information to plymouth. The
> > handling in Plymouth would be very simple: you'd just add a single
> > request which gets a percentage. You show the bar on the first of those
> > you get, you hide the bar if the percentage you get is >= 100. And all
> > the dirty stuff would stay in fsckd. fsckd would probably just take the
> > minimum of the most recent percentage data from all its clients and pass
> > that on to plymouth.

Lennart, you're right, this is the minimal and nature way to implement
the feature. Though I didn't feel very well to invent a fsckd which
was just a bridge between systemd-fsck and plymouth.

Here was my implementation: (The patches are in the attachment, I
guess it may not be merged, hence didn't split the patches, sorry)
1. systemd-fsck will read progress status from fsck, and send it to
plymouth periodicity.
2. plymouth dispatches progress status to
plugins/splash/*/plugin.c(currently only two-step plugin support it),
and let it display the progress status and response for user's cancel
requests.

Note:
1. If more than one systemd-fsck instances running meanwhile, plymouth
will display the first N progress status(and append a "...", if num of
systemd-fsck instances > N).
2. A new protocol is added to plymouth to transport progress status info:
"U\003" + "status" + "detailed_status"
 * "status": nr_of_bytes + status string('\0' terminated). The status
string is something like "fsck:/dev/sda1"
 * "detailed_statis": nr_of_bytes + detailed status string('\0'
terminated). The detailed status string is the progress status info.

Test:
1. Make sure the following options are compiled into kernel:
"""
Device Drivers ->
{*} Connector - unified userspace <-> kernelspace linker -->
    [*]   Report process events to userspace


Networking options -> netfilter
"""
2. Set plymouth's default theme to spinner.
3. touch /forcefsck
4. reboot


Change summary:
= systemd =
== util.c[h] ==
1. alarm_ns(), similar to alarm() but can choose clock_id, and is ns precision.
2. sane_dup2(), similar to dup2() but retry for EINTR.
3. read_all().
4. spawn_async_with_pipes().

== utf8-util.c[h] ==
New files utf8-util.h and  utf8-util.c, code mainly ported from glib
to add utf8 manipulation functions:
1. utf8_find_prev_char()
2. utf8_validate()
3. convert_with_iconv()
4. get_charset()
5. locale_to_utf8()
6. utf8_merge_backspace_char(), removes "bubbles" like "/\b-\b" from a
utf8 line.

== fsck.c ==
if defined FSCK_USE_PRETTY_PROGRESS_INFO, systemd-fsck will use
progress status info formatted by fsck (e.g. "home|=====>  30.6%")

Note, this macro was added because not all fsck.* support -C option.

= plymouth =
== ply-boot-splash-plugin.c[h] ==
1. Add (*update_status_detailed)(...) for ply_boot_splash_plugin_interface_t
2. Add (*on_key_stroke)(...) for ply_boot_splash_plugin_interface_t

== ply-boot-splash.c[h] ==
1. update_status_detailed() was added to process the new protocol
2. ply_boot_splash_on_key_stroke(), let splash plugin have a change to
response user's input.

== main.c ==
1. on_update() hooks to update_status_detailed()
2. on_keyboard_input() hooks to ply_boot_splash_on_key_stroke()

== ply-boot-server.c[h] ==
1. ply_boot_connection_read_request(), add support to the new
protocol(prototype changed!)
2. ply_boot_connection_on_request(), add support to the new protocol
3. (*ply_boot_server_update_handler_t)(...), add support to the new
protocol(prototype changed!);

== two-step/plugin.c ==
Add support to display detailed status

== themes/glow/glow.plymouth.in, themes/spinner/spinner.plymouth.in ==
"""
[fsck]
FsckPrompt=Checking filesystem:
FsckPrompt[zh_CN]=检查文件系统:
CancelFsckPrompt=Press 'C' to skip filesystem check
CancelFsckPrompt[zh_CN]=按下大写'C'键来跳过文件系统检查
CancelKey=C
"""

== ply-key-file.h ==
1. ply_key_file_get_value_locale(), similar to g_key_file_get_locale_string()

== ply-utils.h ==
1. ply_strchug(), ply_strchomp(), ply_strstrip(),
ply_get_locale_variants(), ply_get_language_names() port from glib,
used by ply_key_file_get_value_locale()
2. Move ply_get_process_command_line() and
ply_get_process_parent_pid() to ply-proc.h

== ply-proc.c[h](New files) ==
1. ply_get_process_command_line() and ply_get_process_parent_pid():
moved from ply-utils.h
2. ply_proc_exit_notifier_get(), ply_proc_exit_notifier_put(),
ply_proc_exit_notifier_reset()
ply_proc_exit_notifier_is_attched_event_loop(),
ply_proc_exit_notifier_attach_event_loop(),
ply_proc_exit_notifier_add_exit_cb()
Add a process exit notifier, based on cn_proc[1], it was reference counting.
Basic usage:
1. ply_proc_exit_notifier_get()
2. if ply_proc_exit_notifier_is_attched_event_loop()
        ply_proc_exit_notifier_attach_event_loop()
3. ply_proc_exit_notifier_add_exit_cb() calls cb if has process exited.
4. ply_proc_exit_notifier_put()

ply_proc_exit_notifier_reset() will always clear reference count and
release related resources.


Regards,
-- cee1
----
[1] http://netsplit.com/2011/02/09/the-proc-connector-and-socket-filters/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plymouth-Add-fsck-feedback.patch
Type: text/x-patch
Size: 57444 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/plymouth/attachments/20110620/b676222d/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: systemd-Add-fsck-plymouth-bridge.patch
Type: text/x-patch
Size: 45278 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/plymouth/attachments/20110620/b676222d/attachment-0003.bin>


More information about the plymouth mailing list