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;