SQLite

Check-in [2dc16d345b]
Login

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

Overview
Comment:Improve and update comments.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | winSectorSize
Files: files | file ages | folders
SHA1: 2dc16d345bfb492b2ec69463b6130ff1b62fd291
User & Date: mistachkin 2017-01-18 19:36:10.754
Context
2017-01-18
23:12
For Windows 8.x and higher, require the SQLITE_WIN32_WIN8_SECTOR_SIZE compile-time option in order to enable sector size determination. (Leaf check-in: 47beb55c5b user: mistachkin tags: winSectorSize)
19:36
Improve and update comments. (check-in: 2dc16d345b user: mistachkin tags: winSectorSize)
19:06
Minimize the requested permissions when opening the volume on Windows 7 and Vista. (check-in: 8d429a59cd user: mistachkin tags: winSectorSize)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to src/os_win.c.
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464






465
466
467
468
469
470
471
472
static int winMemInit(void *pAppData);
static void winMemShutdown(void *pAppData);

const sqlite3_mem_methods *sqlite3MemGetWin32(void);
#endif /* SQLITE_WIN32_MALLOC */

/*
** The following variable is (normally) set once and never changes
** thereafter.  It records whether the operating system is Win9x
** or WinNT.
**
** 0:   Operating system unknown.
** 1:   Operating system is Win9x.
** 2:   Operating system is WinNT.
**






** In order to facilitate testing on a WinNT system, the test fixture
** can manually set this value to 1 to emulate Win98 behavior.
*/
#ifdef SQLITE_TEST
LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;
LONG SQLITE_WIN32_VOLATILE sqlite3_os_major = 0;
LONG SQLITE_WIN32_VOLATILE sqlite3_os_minor = 0;
#else







|
|
|

|
|
|

>
>
>
>
>
>
|







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
static int winMemInit(void *pAppData);
static void winMemShutdown(void *pAppData);

const sqlite3_mem_methods *sqlite3MemGetWin32(void);
#endif /* SQLITE_WIN32_MALLOC */

/*
** The following variables are (normally) set once and never change
** thereafter.  They record the major and minor OS version and whether
** the operating system type is Win9x or WinNT.
**
** sqlite3_os_type = 0:   Operating system type is unknown.
** sqlite3_os_type = 1:   Operating system type is Win9x.
** sqlite3_os_type = 2:   Operating system type is WinNT.
**
** For the major and minor versions, the following are the "well-known"
** operating system releases (i.e. the ones that are tested for):
**
** sqlite3_os_major.sqlite3_os_minor = 6.0 = Windows Vista
** sqlite3_os_major.sqlite3_os_minor = 6.2 = Windows 8
**
** In order to facilitate testing on WinNT systems, the test fixture
** can manually set this value to 1 to emulate Win98 behavior.
*/
#ifdef SQLITE_TEST
LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;
LONG SQLITE_WIN32_VOLATILE sqlite3_os_major = 0;
LONG SQLITE_WIN32_VOLATILE sqlite3_os_minor = 0;
#else
3622
3623
3624
3625
3626
3627
3628








3629
3630
3631
3632
3633
3634
3635
      return rc;
    }
#endif
  }
  OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
  return SQLITE_NOTFOUND;
}









#if defined(SQLITE_WIN32_VISTA_SECTOR_SIZE) && \
    defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
/*
** This function attempts to determine if the specified file resides on the
** same volume as the corresponding root directory.  If not, the specified
** file may be impacted by a hard link, symbolic link, or reparse point (e.g.







>
>
>
>
>
>
>
>







3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
      return rc;
    }
#endif
  }
  OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
  return SQLITE_NOTFOUND;
}

/*
** Same-volume determination for versions of Windows prior to Windows 8
** is untested, undocumented, and unsupported.  All such code is omitted
** unless the SQLITE_WIN32_VISTA_SECTOR_SIZE define is set at compile-time,
** and that compile-time option is off by default and undocumented.  The
** following code is for reference only.
*/

#if defined(SQLITE_WIN32_VISTA_SECTOR_SIZE) && \
    defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
/*
** This function attempts to determine if the specified file resides on the
** same volume as the corresponding root directory.  If not, the specified
** file may be impacted by a hard link, symbolic link, or reparse point (e.g.
3685
3686
3687
3688
3689
3690
3691








3692
3693
3694
3695
3696
3697
3698
    }else{
      pFile->lastErrno = osGetLastError();
      winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
                  "winSectorSize1", pFile->zPath);
    }
  }
#endif









#if defined(SQLITE_WIN32_VISTA_SECTOR_SIZE) && \
    defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
  if( osIsVistaPlus() ){
    winFile *pFile = (winFile*)id;
    if( winIsDriveLetterAndColon(pFile->zPath) && winIsOnSameVolume(pFile) ){
      WCHAR zDisk[] = L"\\\\.\\_:\0"; /* underscore will be drive letter */







>
>
>
>
>
>
>
>







3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
    }else{
      pFile->lastErrno = osGetLastError();
      winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
                  "winSectorSize1", pFile->zPath);
    }
  }
#endif

/*
** Sector-size determination for versions of Windows prior to Windows 8
** is untested, undocumented, and unsupported.  All such code is omitted
** unless the SQLITE_WIN32_VISTA_SECTOR_SIZE define is set at compile-time,
** and that compile-time option is off by default and undocumented.  The
** following code is for reference only.
*/

#if defined(SQLITE_WIN32_VISTA_SECTOR_SIZE) && \
    defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
  if( osIsVistaPlus() ){
    winFile *pFile = (winFile*)id;
    if( winIsDriveLetterAndColon(pFile->zPath) && winIsOnSameVolume(pFile) ){
      WCHAR zDisk[] = L"\\\\.\\_:\0"; /* underscore will be drive letter */