From b54feb837cb0a031e4f36a74e532e688900cd9ce Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 18 Jun 2016 20:37:14 +0100 Subject: [PATCH] Don't display "can't bind socket: read only file sytem" error on the first attempt to bind the control socket (immediately after starting). It's pretty normal for the filesystem to be mounted read-only at that stage. --- src/dinit.cc | 10 ++++++---- src/service.cc | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dinit.cc b/src/dinit.cc index 1b8fc65..d7153a3 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -72,7 +72,7 @@ static void close_control_socket() noexcept; static void control_socket_cb(EventLoop_t *loop, int fd); -void open_control_socket() noexcept; +void open_control_socket(bool report_ro_failure = true) noexcept; void setup_external_log() noexcept; @@ -327,7 +327,7 @@ int main(int argc, char **argv) sigterm_watcher.addWatch(eventLoop, SIGTERM); // Try to open control socket (may fail due to readonly filesystem) - open_control_socket(); + open_control_socket(false); #ifdef __linux__ if (am_system_init) { @@ -454,7 +454,7 @@ static void control_socket_cb(EventLoop_t *loop, int sockfd) } } -void open_control_socket() noexcept +void open_control_socket(bool report_ro_failure) noexcept { if (! control_socket_open) { const char * saddrname = control_socket_path; @@ -485,7 +485,9 @@ void open_control_socket() noexcept } if (bind(sockfd, (struct sockaddr *) name, sockaddr_size) == -1) { - log(LogLevel::ERROR, "Error binding control socket: ", strerror(errno)); + if (errno != EROFS || report_ro_failure) { + log(LogLevel::ERROR, "Error binding control socket: ", strerror(errno)); + } close(sockfd); free(name); return; diff --git a/src/service.cc b/src/service.cc index c81b0cb..4638854 100644 --- a/src/service.cc +++ b/src/service.cc @@ -23,7 +23,7 @@ */ // from dinit.cc: -void open_control_socket() noexcept; +void open_control_socket(bool report_ro_failure = true) noexcept; void setup_external_log() noexcept; extern EventLoop_t eventLoop; -- 2.25.1