chiark / gitweb /
dbus: make errors reported via D-Bus more useful
[elogind.git] / src / automount.c
index b8d7ad25f4d9a938bf1bb9c21df19497d2cb6c2e..39eb3dd01aafd677e64624c8f1b8745b0e422acc 100644 (file)
@@ -35,6 +35,7 @@
 #include "load-dropin.h"
 #include "unit-name.h"
 #include "dbus-automount.h"
+#include "bus-errors.h"
 
 static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
         [AUTOMOUNT_DEAD] = UNIT_INACTIVE,
@@ -125,10 +126,7 @@ int automount_add_one_mount_link(Automount *a, Mount *m) {
         if (path_equal(a->where, m->where))
                 return 0;
 
-        if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(a), true)) < 0)
-                return r;
-
-        if ((r = unit_add_dependency(UNIT(a), UNIT_REQUIRES, UNIT(m), true)) < 0)
+        if ((r = unit_add_two_dependencies(UNIT(a), UNIT_AFTER, UNIT_REQUIRES, UNIT(m), true)) < 0)
                 return r;
 
         return 0;
@@ -536,10 +534,13 @@ fail:
 static void automount_enter_runnning(Automount *a) {
         int r;
         struct stat st;
+        DBusError error;
 
         assert(a);
         assert(a->mount);
 
+        dbus_error_init(&error);
+
         mkdir_p(a->where, a->directory_mode);
 
         /* Before we do anything, let's see if somebody is playing games with us? */
@@ -550,8 +551,8 @@ static void automount_enter_runnning(Automount *a) {
 
         if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
                 log_info("%s's automount point already active?", a->meta.id);
-        else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, NULL)) < 0) {
-                log_warning("%s failed to queue mount startup job: %s", a->meta.id, strerror(-r));
+        else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) {
+                log_warning("%s failed to queue mount startup job: %s", a->meta.id, bus_error(&error, r));
                 goto fail;
         }
 
@@ -560,6 +561,7 @@ static void automount_enter_runnning(Automount *a) {
 
 fail:
         automount_enter_dead(a, false);
+        dbus_error_free(&error);
 }
 
 static int automount_start(Unit *u) {