From: Davin McCall Date: Sat, 18 Jun 2016 19:37:14 +0000 (+0100) Subject: Don't display "can't bind socket: read only file sytem" error on the X-Git-Tag: v0.03~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b54feb837cb0a031e4f36a74e532e688900cd9ce;p=oweals%2Fdinit.git 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. --- 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;