chiark / gitweb /
core: output unit status output strings to console, only if we actually are changing...
[elogind.git] / src / core / automount.c
index 3f34a2895f2c11186700b9faeec0a917f5ebaad7..d47e6fa8dc3214b6a11bf29dfce8bcbd517096ea 100644 (file)
@@ -75,7 +75,7 @@ static void repeat_unmount(const char *path) {
                         continue;
 
                 if (errno != EINVAL)
-                        log_error("Failed to unmount: %m");
+                        log_error_errno(errno, "Failed to unmount: %m");
 
                 break;
         }
@@ -300,10 +300,8 @@ static int open_dev_autofs(Manager *m) {
         label_fix("/dev/autofs", false, false);
 
         m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
-        if (m->dev_autofs_fd < 0) {
-                log_error("Failed to open /dev/autofs: %m");
-                return -errno;
-        }
+        if (m->dev_autofs_fd < 0)
+                return log_error_errno(errno, "Failed to open /dev/autofs: %m");
 
         init_autofs_dev_ioctl(&param);
         if (ioctl(m->dev_autofs_fd, AUTOFS_DEV_IOCTL_VERSION, &param) < 0) {
@@ -605,7 +603,7 @@ static int automount_start(Unit *u) {
 
         a->result = AUTOMOUNT_SUCCESS;
         automount_enter_waiting(a);
-        return 0;
+        return 1;
 }
 
 static int automount_stop(Unit *u) {
@@ -615,7 +613,7 @@ static int automount_stop(Unit *u) {
         assert(a->state == AUTOMOUNT_WAITING || a->state == AUTOMOUNT_RUNNING);
 
         automount_enter_dead(a, AUTOMOUNT_SUCCESS);
-        return 0;
+        return 1;
 }
 
 static int automount_serialize(Unit *u, FILE *f, FDSet *fds) {
@@ -744,7 +742,10 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
 
         l = loop_read(a->pipe_fd, &packet, sizeof(packet), true);
         if (l != sizeof(packet)) {
-                log_unit_error(UNIT(a)->id, "Invalid read from pipe: %s", l < 0 ? strerror(-l) : "short read");
+                if (l < 0)
+                        log_unit_error_errno(UNIT(a)->id, l, "Invalid read from pipe: %m");
+                else
+                        log_unit_error(UNIT(a)->id, "Invalid read from pipe: short read");
                 goto fail;
         }
 
@@ -757,7 +758,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
 
                         get_process_comm(packet.v5_packet.pid, &p);
                         log_unit_info(UNIT(a)->id,
-                                       "Got automount request for %s, triggered by "PID_FMT" (%s)",
+                                       "Got automount request for %s, triggered by %"PRIu32" (%s)",
                                        a->where, packet.v5_packet.pid, strna(p));
                 } else
                         log_unit_debug(UNIT(a)->id, "Got direct mount request on %s", a->where);
@@ -806,6 +807,17 @@ static void automount_reset_failed(Unit *u) {
         a->result = AUTOMOUNT_SUCCESS;
 }
 
+static bool automount_supported(Manager *m) {
+        static int supported = -1;
+
+        assert(m);
+
+        if (supported < 0)
+                supported = access("/dev/autofs", F_OK) >= 0;
+
+        return supported;
+}
+
 static const char* const automount_state_table[_AUTOMOUNT_STATE_MAX] = {
         [AUTOMOUNT_DEAD] = "dead",
         [AUTOMOUNT_WAITING] = "waiting",
@@ -858,6 +870,7 @@ const UnitVTable automount_vtable = {
         .bus_vtable = bus_automount_vtable,
 
         .shutdown = automount_shutdown,
+        .supported = automount_supported,
 
         .status_message_formats = {
                 .finished_start_job = {