summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-09-21 04:25:48 +0200
committerLennart Poettering <lennart@poettering.net>2010-09-21 04:25:48 +0200
commit05d6a3b6cff405e43fd95a26e342b9233b21269b (patch)
tree64283391943394b3bfe0eb0122b2b48849e2e8bd
parentb0c918b97f1abb160d8df2b94deb03efcb4fcf8f (diff)
manager: calculate progress value while booting
-rw-r--r--src/dbus-manager.c19
-rw-r--r--src/systemctl.c8
2 files changed, 27 insertions, 0 deletions
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index c08781d576..53dbeac2c4 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -221,6 +221,24 @@ static int bus_manager_append_n_jobs(Manager *m, DBusMessageIter *i, const char
return 0;
}
+static int bus_manager_append_progress(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ double d;
+
+ assert(m);
+ assert(i);
+ assert(property);
+
+ if (dual_timestamp_is_set(&m->finish_timestamp))
+ d = 1.0;
+ else
+ d = 1.0 - ((double) hashmap_size(m->jobs) / (double) m->n_installed_jobs);
+
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_DOUBLE, &d))
+ return -ENOMEM;
+
+ return 0;
+}
+
static const char *message_get_sender_with_fallback(DBusMessage *m) {
const char *s;
@@ -248,6 +266,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NInstalledJobs",bus_property_append_uint32, "u", &m->n_installed_jobs },
+ { "org.freedesktop.systemd1.Manager", "Progress", bus_manager_append_progress, "d", NULL },
{ "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment },
{ "org.freedesktop.systemd1.Manager", "ConfirmSpawn", bus_property_append_bool, "b", &m->confirm_spawn },
{ "org.freedesktop.systemd1.Manager", "ShowStatus", bus_property_append_bool, "b", &m->show_status },
diff --git a/src/systemctl.c b/src/systemctl.c
index 525e2f0b17..2525967bcc 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -2003,6 +2003,14 @@ static int print_property(const char *name, DBusMessageIter *iter) {
return 0;
}
+ case DBUS_TYPE_DOUBLE: {
+ double d;
+ dbus_message_iter_get_basic(iter, &d);
+
+ printf("%s=%g\n", name, d);
+ return 0;
+ }
+
case DBUS_TYPE_STRUCT: {
DBusMessageIter sub;
dbus_message_iter_recurse(iter, &sub);