Browse Source

Slightly improve behaviour and documentation for starts-rwfs option

Davin McCall 1 year ago
parent
commit
7c3fc11cda
2 changed files with 12 additions and 8 deletions
  1. 5 1
      doc/manpages/dinit-service.5.m4
  2. 7 7
      src/dinit.cc

+ 5 - 1
doc/manpages/dinit-service.5.m4

@@ -478,7 +478,11 @@ this option.
 \fBstarts\-rwfs\fR
 This service mounts the root filesystem read/write (or at least mounts the
 normal writable filesystems for the system).
-This prompts Dinit to create its control socket, if it has not already managed to do so.
+This prompts Dinit to attempt to create its control socket, if it has not already managed to do so,
+and similarly log boot time to the system \fBwtmp\fR(5) database (if supported) if not yet done.
+This option may be specified on multiple services, which may be useful if the wtmp database becomes
+writable at a different stage than the control socket location becomes writable, for example.
+It
 .TP
 \fBstarts\-log\fR
 This service starts the system log daemon.

+ 7 - 7
src/dinit.cc

@@ -795,23 +795,23 @@ static void control_socket_ready() noexcept {
     if (socket_ready_fd > 2) {
         close(socket_ready_fd);
     }
-    // Ensure this can only be called once
+    // Ensure that we don't try to issue readiness again:
     socket_ready_fd = -1;
 }
 
 // Callback when the root filesystem is read/write:
 void rootfs_is_rw() noexcept
 {
-    open_control_socket(true);
-    if (! did_log_boot) {
+    if (!control_socket_open) {
+        open_control_socket(true);
+        control_socket_ready();
+    }
+    if (!did_log_boot) {
         did_log_boot = log_boot();
     }
-    // If the control socket failed to open early on, there was no readiness
-    // notification, so do it here for a second time, just in case
-    control_socket_ready();
 }
 
-// Open/create the control socket, normally /dev/dinitctl, used to allow client programs to connect
+// Open/create the control socket, normally /run/dinitctl, used to allow client programs to connect
 // and issue service orders and shutdown commands etc. This can safely be called multiple times;
 // once the socket has been successfully opened, further calls will check the socket file is still
 // present and re-create it if not.