mdbx: улучшение авто-переключения в режим without-lck при открытии БД на read-only-носителе.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-01-12 02:32:12 +03:00
parent 92a49c7c8c
commit 0297136648

View File

@ -135,25 +135,22 @@ __cold int lck_setup(MDBX_env *env, mdbx_mode_t mode) {
switch (err) { switch (err) {
default: default:
return err; return err;
case MDBX_ENOFILE:
case MDBX_EACCESS: case MDBX_EACCESS:
case MDBX_EPERM: case MDBX_EPERM:
if (!F_ISSET(env->flags, MDBX_RDONLY | MDBX_EXCLUSIVE)) if (!F_ISSET(env->flags, MDBX_RDONLY | MDBX_EXCLUSIVE))
return err; return err;
break; break;
case MDBX_ENOFILE:
case MDBX_EROFS: case MDBX_EROFS:
if ((env->flags & MDBX_RDONLY) == 0) if ((env->flags & MDBX_RDONLY) == 0)
return err; return err;
break;
}
if (err != MDBX_ENOFILE) {
/* ENSURE the file system is read-only */ /* ENSURE the file system is read-only */
err = osal_check_fs_rdonly(env->lazy_fd, env->pathname.lck, err); err = osal_check_fs_rdonly(env->lazy_fd, env->pathname.lck, err);
if (err != MDBX_SUCCESS && if (err != MDBX_SUCCESS &&
/* ignore ERROR_NOT_SUPPORTED for exclusive mode */ /* ignore ERROR_NOT_SUPPORTED for exclusive mode */
!(err == MDBX_ENOSYS && (env->flags & MDBX_EXCLUSIVE))) !(err == MDBX_ENOSYS && (env->flags & MDBX_EXCLUSIVE)))
return err; return err;
break;
} }
/* LY: without-lck mode (e.g. exclusive or on read-only filesystem) */ /* LY: without-lck mode (e.g. exclusive or on read-only filesystem) */