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.
This commit is contained in:
Gabriel Ebner 2016-01-16 09:26:45 +01:00 committed by Leonardo de Moura
parent 86fc326e08
commit 7e11c5cf6e

View file

@ -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.