From aaa3f2214e88374475adde0af0a6916f114a0b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 19 Feb 2019 11:51:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=B8=D1=8F=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20plymouthd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Запускать plymouthd при загрузке если есть параметр splash или splash=silent Запускать plymouthd при выключении если есть параметр splash или splash=shutdown --- plymouth.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/plymouth.c b/plymouth.c index f2658f6..48a69e8 100644 --- a/plymouth.c +++ b/plymouth.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -174,6 +176,30 @@ bool ply_update_status(int hook, const char* name) return true; } +bool kernel_command_has_argument(const char *argument) +{ + char buf[4096]; + int fd; + fd = open("/proc/cmdline", O_RDONLY); + + if( fd < 0 ) { + return false; + } + if(read(fd, buf, 4095) < 0) { + close(fd); + return false; + } + close(fd); + char *found_arg = strstr(buf, argument); + if(found_arg == NULL) + return false; + + if(found_arg == buf || found_arg[-1] == ' ') { + char endch = *(found_arg+strlen(argument)); + return (isspace(endch) || endch == '\0') ? true : false; + } + return false; +} bool ply_update_rootfs_rw() { @@ -236,7 +262,10 @@ int rc_plugin_hook(RC_HOOK hook, const char *name) case RC_HOOK_RUNLEVEL_STOP_IN: /* Start the Plymouth daemon and show splash when system is being shut * down. */ - if(strcmp(name, RC_LEVEL_SHUTDOWN) == 0) { + if(strcmp(name, RC_LEVEL_SHUTDOWN) == 0 && + (kernel_command_has_argument("splash") || + kernel_command_has_argument("splash=shutdown"))) + { DBG("ply_start(PLY_MODE_SHUTDOWN)"); if(!ply_start(PLY_MODE_SHUTDOWN) || !ply_update_rootfs_rw()) @@ -249,7 +278,10 @@ int rc_plugin_hook(RC_HOOK hook, const char *name) /* Start the Plymouth daemon and show splash when entering the boot * runlevel. Required /proc and /sys should already be mounted in * sysinit runlevel. */ - if(strcmp(name, bootlevel) == 0) { + if(strcmp(name, bootlevel) == 0 && + (kernel_command_has_argument("splash") || + kernel_command_has_argument("splash=silent"))) + { DBG("ply_start(PLY_MODE_BOOT)"); if(!ply_start(PLY_MODE_BOOT)) rv = 1;