Skip to content
Permalink
Browse files
Merge branch 'mer1678_end_rescue_mode' into 'master'
Disable rescue mode when/if init done is reached



See merge request !16
  • Loading branch information
spiiroin committed Oct 18, 2016
2 parents 8714bf4 + a53740d commit 91ceea335dd8b8d3b2a2b49eb36c4b6420a4a042
Showing with 35 additions and 0 deletions.
  1. +19 −0 src/usb_moded-dbus.c
  2. +16 −0 src/usb_moded.c
@@ -39,6 +39,10 @@
#include "usb_moded-network.h"
#include "usb_moded-log.h"

#define INIT_DONE_INTERFACE "com.nokia.startup.signal"
#define INIT_DONE_SIGNAL "init_done"
#define INIT_DONE_MATCH "type='signal',interface='"INIT_DONE_INTERFACE"',member='"INIT_DONE_SIGNAL"'"

static DBusConnection *dbus_connection_sys = NULL;
extern gboolean rescue_mode;

@@ -129,6 +133,18 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa

if(!interface || !member || !object) goto EXIT;

if( type == DBUS_MESSAGE_TYPE_SIGNAL )
{
if( !strcmp(interface, INIT_DONE_INTERFACE) && !strcmp(member, INIT_DONE_SIGNAL) ) {
/* Auto-disable rescue mode when bootup is finished */
if( rescue_mode ) {
rescue_mode = FALSE;
log_debug("init done reached - rescue mode disabled");
}
}
goto EXIT;
}

if( type == DBUS_MESSAGE_TYPE_METHOD_CALL && !strcmp(interface, USB_MODE_INTERFACE) && !strcmp(object, USB_MODE_OBJECT))
{
status = DBUS_HANDLER_RESULT_HANDLED;
@@ -403,6 +419,9 @@ gboolean usb_moded_dbus_init(void)
dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error);
*/

/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);

dbus_threads_init_default();

/* Connect D-Bus to the mainloop */
@@ -1052,6 +1052,16 @@ void delay_suspend(void)
allow_suspend_cb, 0);
}

/** Check if system has already been successfully booted up
*
* @return true if init-done has been reached, or false otherwise
*/
static bool init_done_p(void)
{
return access("/run/systemd/boot-status/init-done", F_OK) == 0;
}


int main(int argc, char* argv[])
{
int result = EXIT_FAILURE;
@@ -1146,6 +1156,12 @@ int main(int argc, char* argv[])
#endif
mainloop = g_main_loop_new(NULL, FALSE);

if (rescue_mode && init_done_p())
{
rescue_mode = FALSE;
log_warning("init done passed; rescue mode ignored");
}

/* init daemon into a clean state first, then dbus and hw_abstraction last */
usb_moded_init();
if( !usb_moded_dbus_init() )

0 comments on commit 91ceea3

Please sign in to comment.