mdbx-windows: refine/fix mdbx_check_fs_local() for CDROM case.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-06-04 02:08:24 +03:00
parent 73fbf5c8fa
commit 77f56541d0

View File

@ -1186,21 +1186,25 @@ static int mdbx_check_fs_local(mdbx_filehandle_t handle, int flags) {
} }
} }
if (!mdbx_GetFinalPathNameByHandleW(handle, PathBuffer, INT16_MAX, if (mdbx_GetFinalPathNameByHandleW(handle, PathBuffer, INT16_MAX,
FILE_NAME_NORMALIZED | FILE_NAME_NORMALIZED | VOLUME_NAME_NT)) {
VOLUME_NAME_NT)) { if (_wcsnicmp(PathBuffer, L"\\Device\\Mup\\", 12) == 0) {
rc = (int)GetLastError(); if (!(flags & MDBX_EXCLUSIVE)) {
rc = ERROR_REMOTE_STORAGE_MEDIA_ERROR;
goto bailout;
}
}
}
if (F_ISSET(flags, MDBX_RDONLY | MDBX_EXCLUSIVE) &&
(FileSystemFlags & FILE_READ_ONLY_VOLUME)) {
/* without-LCK (exclusive readonly) mode for DB on a read-only volume */
goto bailout; goto bailout;
} }
if (_wcsnicmp(PathBuffer, L"\\Device\\Mup\\", 12) == 0) { if (mdbx_GetFinalPathNameByHandleW(handle, PathBuffer, INT16_MAX,
if (!(flags & MDBX_EXCLUSIVE)) { FILE_NAME_NORMALIZED |
rc = ERROR_REMOTE_STORAGE_MEDIA_ERROR; VOLUME_NAME_DOS)) {
goto bailout;
}
} else if (mdbx_GetFinalPathNameByHandleW(handle, PathBuffer, INT16_MAX,
FILE_NAME_NORMALIZED |
VOLUME_NAME_DOS)) {
UINT DriveType = GetDriveTypeW(PathBuffer); UINT DriveType = GetDriveTypeW(PathBuffer);
if (DriveType == DRIVE_NO_ROOT_DIR && if (DriveType == DRIVE_NO_ROOT_DIR &&
_wcsnicmp(PathBuffer, L"\\\\?\\", 4) == 0 && _wcsnicmp(PathBuffer, L"\\\\?\\", 4) == 0 &&
@ -1226,6 +1230,7 @@ static int mdbx_check_fs_local(mdbx_filehandle_t handle, int flags) {
break; break;
} }
} }
bailout: bailout:
mdbx_free(PathBuffer); mdbx_free(PathBuffer);
return rc; return rc;