From: mistachkin Date: Wed, 11 Jan 2017 16:52:42 +0000 (+0000) Subject: Attempt to detect physical sector sizes on Windows 8 and higher. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e37d48f4a644186c219a9b14d59c5b14aaf9b9b;p=thirdparty%2Fsqlite.git Attempt to detect physical sector sizes on Windows 8 and higher. FossilOrigin-Name: 381fd34b97ffe14f4bb784a9aae74477af699a08 --- diff --git a/manifest b/manifest index 60b608e6c7..5d19083135 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sSTAT4\scomputations,\sensure\sthat\sthe\saAvgEq\svalues\sdo\snot\sgo\snegative. -D 2017-01-11T14:15:29.635 +C Attempt\sto\sdetect\sphysical\ssector\ssizes\son\sWindows\s8\sand\shigher. +D 2017-01-11T16:52:42.051 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -373,7 +373,7 @@ F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 -F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9 +F src/os_win.c 036b12e525724d3cbdd931a6e4439dea924b17bf F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9dc72d23eebbdf992bd69f2ab954d0d3a27c7340 F src/pager.h d1e944291030351f362a0a7da9b5c3e34e603e39 @@ -1543,7 +1543,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e500c15a9f55aed1601f7c14169dd56fd76f1fdd -R 5c2e2ea0b7d53513cb0d1e5b25773986 -U drh -Z ed5473ac37dfd76118f46ef5f94f7fb6 +P f58f75b5a06f88ba97bd1a02bee621c64691c6f8 +R d576d3178105de663378d6b438b5e84a +T *branch * winSectorSize +T *sym-winSectorSize * +T -sym-trunk * +U mistachkin +Z dade53828d1ccfadec45e309319f8c1a diff --git a/manifest.uuid b/manifest.uuid index 1657a590c9..80c622bc30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f58f75b5a06f88ba97bd1a02bee621c64691c6f8 \ No newline at end of file +381fd34b97ffe14f4bb784a9aae74477af699a08 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 2cb5f7b0c8..af731fa7bc 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -68,6 +68,10 @@ ** Define the required Windows SDK version constants if they are not ** already available. */ +#ifndef _WIN32_WINNT_WIN8 +# define _WIN32_WINNT_WIN8 0x0602 +#endif + #ifndef NTDDI_WIN8 # define NTDDI_WIN8 0x06020000 #endif @@ -1010,7 +1014,8 @@ static struct win_syscall { #define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent) -#if SQLITE_OS_WINRT +#if SQLITE_OS_WINRT || (defined(_WIN32_WINNT) && \ + _WIN32_WINNT >= _WIN32_WINNT_WIN8) { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, #else { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, @@ -3549,7 +3554,24 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ ** same for both. */ static int winSectorSize(sqlite3_file *id){ +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN8 + winFile *pFile = (winFile*)id; + FILE_STORAGE_INFO info; + if( osGetFileInformationByHandleEx(pFile->h, FileStorageInfo, + &info, sizeof(info)) ){ + ULONG size = info.FileSystemEffectivePhysicalBytesPerSectorForAtomicity; + OSTRACE(("SECTOR file=%p, size=%lu\n", pFile->h, size)); + if( size>0 && size<=2147483647 ){ + return (int)size; + } + }else{ + pFile->lastErrno = osGetLastError(); + winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, + "winSectorSize", pFile->zPath); + } +#else (void)id; +#endif return SQLITE_DEFAULT_SECTOR_SIZE; }