chiark / gitweb /
core/dbus-unit: modernize style
[elogind.git] / src / core / automount.c
index 5b1f544f0859514a115d140359e8822d44dc53b6..74776646f632b5b7e1cbd6e9b254e9d2f7729788 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "unit.h"
 #include "automount.h"
+#include "mount.h"
 #include "load-fragment.h"
 #include "load-dropin.h"
 #include "unit-name.h"
@@ -40,6 +41,7 @@
 #include "label.h"
 #include "mkdir.h"
 #include "path-util.h"
+#include "dbus-common.h"
 
 static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
         [AUTOMOUNT_DEAD] = UNIT_INACTIVE,
@@ -506,8 +508,7 @@ static void automount_enter_waiting(Automount *a) {
         /* We knowingly ignore the results of this call */
         mkdir_p_label(a->where, 0555);
 
-        if (dir_is_empty(a->where) <= 0)
-                log_notice("%s: Directory %s to mount over is not empty, mounting anyway. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", a->meta.id, a->where);
+        warn_if_dir_nonempty(a->meta.id, a->where);
 
         if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) {
                 r = -errno;
@@ -585,7 +586,7 @@ fail:
 static void automount_enter_runnning(Automount *a) {
         int r;
         struct stat st;
-        DBusError error;
+        _cleanup_dbus_error_free_ DBusError error;
 
         assert(a);
         assert(UNIT_DEREF(a->mount));
@@ -620,7 +621,6 @@ static void automount_enter_runnning(Automount *a) {
 
 fail:
         automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
-        dbus_error_free(&error);
 }
 
 static int automount_start(Unit *u) {
@@ -791,13 +791,11 @@ static void automount_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
         case autofs_ptype_missing_direct:
 
                 if (packet.v5_packet.pid > 0) {
-                        char *p = NULL;
+                        _cleanup_free_ char *p = NULL;
 
                         get_process_comm(packet.v5_packet.pid, &p);
                         log_debug("Got direct mount request on %s, triggered by %lu (%s)",
                                   a->where, (unsigned long) packet.v5_packet.pid, strna(p));
-                        free(p);
-
                 } else
                         log_debug("Got direct mount request on %s", a->where);