diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-04-13 19:45:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-04-13 19:46:51 +0200 |
commit | 2dad62205f3412198769f227ac4a1130f7887eec (patch) | |
tree | 49ac43930650e3abe00729a39df1be5a3b213070 | |
parent | 186b97d99fc4017d9c88221791bf8423130a9a1f (diff) |
dbus: expose whether we have a hardware watchdog on the bus
-rw-r--r-- | src/core/dbus-manager.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 46b47849d2..88945b5c64 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -242,7 +242,8 @@ " <property name=\"DefaultStandardOutput\" type=\"s\" access=\"read\"/>\n" \ " <property name=\"DefaultStandardError\" type=\"s\" access=\"read\"/>\n" \ " <property name=\"RuntimeWatchdogUSec\" type=\"s\" access=\"read\"/>\n" \ - " <property name=\"ShutdownWatchdogUSec\" type=\"s\" access=\"read\"/>\n" + " <property name=\"ShutdownWatchdogUSec\" type=\"s\" access=\"read\"/>\n" \ + " <property name=\"HaveWatchdog\" type=\"b\" access=\"read\"/>\n" #ifdef HAVE_SYSV_COMPAT #define BUS_MANAGER_INTERFACE_PROPERTIES_SYSV \ @@ -493,6 +494,20 @@ static int bus_manager_send_unit_files_changed(Manager *m) { return r; } +static int bus_manager_append_have_watchdog(DBusMessageIter *i, const char *property, void *data) { + dbus_bool_t b; + + assert(i); + assert(property); + + b = access("/dev/watchdog", F_OK) >= 0; + + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b)) + return -ENOMEM; + + return 0; +} + static const char systemd_property_string[] = PACKAGE_STRING "\0" DISTRIBUTION "\0" @@ -534,6 +549,7 @@ static const BusProperty bus_manager_properties[] = { { "DefaultStandardError", bus_manager_append_exec_output, "s", offsetof(Manager, default_std_error) }, { "RuntimeWatchdogUSec", bus_property_append_usec, "t", offsetof(Manager, runtime_watchdog), }, { "ShutdownWatchdogUSec", bus_property_append_usec, "t", offsetof(Manager, shutdown_watchdog), }, + { "HaveWatchdog", bus_manager_append_have_watchdog, "b", 0 }, #ifdef HAVE_SYSV_COMPAT { "SysVConsole", bus_property_append_bool, "b", offsetof(Manager, sysv_console) }, { "SysVInitPath", bus_property_append_strv, "as", offsetof(Manager, lookup_paths.sysvinit_path), true }, |