mdbx: логирование ошибок при открытии lck-файла.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-01-12 14:30:39 +03:00
parent 8408a2eed3
commit e5fe279632

View File

@ -133,28 +133,33 @@ __cold int lck_setup(MDBX_env *env, mdbx_mode_t mode) {
int err = osal_openfile(MDBX_OPEN_LCK, env, env->pathname.lck, &env->lck_mmap.fd, mode);
if (err != MDBX_SUCCESS) {
switch (err) {
default:
return err;
case MDBX_EACCESS:
case MDBX_EPERM:
if (!F_ISSET(env->flags, MDBX_RDONLY | MDBX_EXCLUSIVE))
return err;
break;
if (F_ISSET(env->flags, MDBX_RDONLY | MDBX_EXCLUSIVE))
break;
__fallthrough /* fall through */;
case MDBX_ENOFILE:
case MDBX_EROFS:
if ((env->flags & MDBX_RDONLY) == 0)
return err;
/* ENSURE the file system is read-only */
err = osal_check_fs_rdonly(env->lazy_fd, env->pathname.lck, err);
if (err != MDBX_SUCCESS &&
/* ignore ERROR_NOT_SUPPORTED for exclusive mode */
!(err == MDBX_ENOSYS && (env->flags & MDBX_EXCLUSIVE)))
return err;
break;
if (env->flags & MDBX_RDONLY) {
/* ENSURE the file system is read-only */
int err_rofs = osal_check_fs_rdonly(env->lazy_fd, env->pathname.lck, err);
if (err_rofs == MDBX_SUCCESS ||
/* ignore ERROR_NOT_SUPPORTED for exclusive mode */
(err_rofs == MDBX_ENOSYS && (env->flags & MDBX_EXCLUSIVE)))
break;
if (err_rofs != MDBX_ENOSYS)
err = err_rofs;
}
__fallthrough /* fall through */;
default:
ERROR("unable to open lck-file %" MDBX_PRIsPATH ", env-flags 0x%X, err %d", env->pathname.lck, env->flags, err);
return err;
}
/* LY: without-lck mode (e.g. exclusive or on read-only filesystem) */
env->lck_mmap.fd = INVALID_HANDLE_VALUE;
NOTICE("continue %" MDBX_PRIsPATH " within without-lck mode, env-flags 0x%X, lck-error %d", env->pathname.dxb,
env->flags, err);
}
rthc_lock();