/ Check-in [381fd34b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Attempt to detect physical sector sizes on Windows 8 and higher.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winSectorSize
Files: files | file ages | folders
SHA1:381fd34b97ffe14f4bb784a9aae74477af699a08
User & Date: mistachkin 2017-01-11 16:52:42
Context
2017-01-12
23:37
Attempt to detect physical sector sizes on Windows Vista and higher. check-in: 6e388423 user: mistachkin tags: winSectorSize
2017-01-11
16:52
Attempt to detect physical sector sizes on Windows 8 and higher. check-in: 381fd34b user: mistachkin tags: winSectorSize
14:15
In the STAT4 computations, ensure that the aAvgEq values do not go negative. check-in: f58f75b5 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

64
65
66
67
68
69
70




71
72
73
74
75
76
77
....
1006
1007
1008
1009
1010
1011
1012
1013

1014
1015
1016
1017
1018
1019
1020
....
3545
3546
3547
3548
3549
3550
3551
















3552

3553
3554
3555
3556
3557
3558
3559
 must be defined."
#endif

/*
** Define the required Windows SDK version constants if they are not
** already available.
*/




#ifndef NTDDI_WIN8
#  define NTDDI_WIN8                        0x06020000
#endif

#ifndef NTDDI_WINBLUE
#  define NTDDI_WINBLUE                     0x06030000
#endif
................................................................................
#else
  { "SetFilePointerEx",        (SYSCALL)0,                       0 },
#endif

#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \
        PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)

#if SQLITE_OS_WINRT

  { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },
#else
  { "GetFileInformationByHandleEx", (SYSCALL)0,                  0 },
#endif

#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)
................................................................................
**
** SQLite code assumes this function cannot fail. It also assumes that
** if two files are created in the same file-system directory (i.e.
** a database and its journal file) that the sector size will be the
** same for both.
*/
static int winSectorSize(sqlite3_file *id){
















  (void)id;

  return SQLITE_DEFAULT_SECTOR_SIZE;
}

/*
** Return a vector of device characteristics.
*/
static int winDeviceCharacteristics(sqlite3_file *id){







>
>
>
>







 







|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
....
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
....
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
 must be defined."
#endif

/*
** 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

#ifndef NTDDI_WINBLUE
#  define NTDDI_WINBLUE                     0x06030000
#endif
................................................................................
#else
  { "SetFilePointerEx",        (SYSCALL)0,                       0 },
#endif

#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \
        PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)

#if SQLITE_OS_WINRT || (defined(_WIN32_WINNT) && \
        _WIN32_WINNT >= _WIN32_WINNT_WIN8)
  { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },
#else
  { "GetFileInformationByHandleEx", (SYSCALL)0,                  0 },
#endif

#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)
................................................................................
**
** SQLite code assumes this function cannot fail. It also assumes that
** if two files are created in the same file-system directory (i.e.
** a database and its journal file) that the sector size will be the
** 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;
}

/*
** Return a vector of device characteristics.
*/
static int winDeviceCharacteristics(sqlite3_file *id){