From 7e11c5cf6ee0972c39b68dc65bd676c1f1336e07 Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sat, 16 Jan 2016 09:26:45 +0100 Subject: [PATCH] fix(src/util/file_lock): ignore failure to create locks on read-only file systems EACCES is already ignored when creating lock files. In this case we assume that the file to be locked is part of the system-wide installation. On NixOS however, the file system containing system packages is mounted read-only, and open(2) returns EROFS. --- src/util/file_lock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/file_lock.cpp b/src/util/file_lock.cpp index a4a9f2b51b..7c7ea1b156 100644 --- a/src/util/file_lock.cpp +++ b/src/util/file_lock.cpp @@ -78,7 +78,7 @@ file_lock::file_lock(char const * fname, bool exclusive): m_fname += ".lock"; m_fd = open(m_fname.c_str(), O_CREAT, 0xFFFF); if (m_fd == -1) { - if (errno == EACCES) { + if (errno == EACCES || errno == EROFS) { // We don't have permission to create the file, the folder containing fname is probably readonly. // fname is probably part of the Lean installation in a system directory. // So, we ignore the file_lock in this case.