From: drh Date: Mon, 2 Jan 2012 18:20:14 +0000 (+0000) Subject: Remove the code that attempts to find the sector size from the OS and X-Git-Tag: mountain-lion~8^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8942d4125ea63c485d0252eebab31e38003607eb;p=thirdparty%2Fsqlite.git Remove the code that attempts to find the sector size from the OS and hardcode the xSectorSize methods of the unix and windows VFSes to return SQLITE_DEFAULT_SECTOR_SIZE, which is now set to 4096 unless overridden. FossilOrigin-Name: 03d8362cd2cadab8e1cc5b18a3194152f2bd0a84 --- diff --git a/manifest b/manifest index b5bf9bdea3..182ee59812 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\spage\squantities\sin\spcache1.c\sto\sunsigned. -D 2012-01-02T18:00:55.564 +C Remove\sthe\scode\sthat\sattempts\sto\sfind\sthe\ssector\ssize\sfrom\sthe\sOS\sand\nhardcode\sthe\sxSectorSize\smethods\sof\sthe\sunix\sand\swindows\sVFSes\sto\sreturn\nSQLITE_DEFAULT_SECTOR_SIZE,\swhich\sis\snow\sset\sto\s4096\sunless\soverridden. +D 2012-01-02T18:20:14.209 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,11 +163,11 @@ F src/mutex_unix.c b4f4e923bb8de93ec3f251fadb50855f23df9579 F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c 519bdf7c608c4848024e1d87934f9305454145f4 -F src/os.h 549b1a2e5e0ed1e1499f252dac126c4973e7379c +F src/os.h c7d888830f168a9b681b3aec30789f4ad2445c17 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 3a441671f35569df4b72641e928fdb1ab5cd8576 -F src/os_win.c 569fe7448e781bfb8116aa79081df0eadf576fc6 +F src/os_unix.c 51acd5477f7c92321bbc665282a710556f19b4a7 +F src/os_win.c 0d3522dd0ad82b615748d4d391211af62b57ae03 F src/pager.c a21a3191ab75310ea75bb61149e63b835f77f5f0 F src/pager.h 5cd760857707529b403837d813d86b68938d6183 F src/parse.y fabb2e7047417d840e6fdb3ef0988a86849a08ba @@ -986,7 +986,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c1691d998a03fee3bef137ccf2e8ca45acac2df4 -R 84be2ca283aa4d12d0883d5cb3ef90ca +P da52e6e8b490508bc1ee4700aa45a79f398363da +R a0b8de10aeee04558967b4b25ead4061 U drh -Z 981c2603df115cccf0c78e5588d3bb18 +Z d686dcd0a4de73c84f2800d730af321e diff --git a/manifest.uuid b/manifest.uuid index 1b3a2f307c..44d9031030 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da52e6e8b490508bc1ee4700aa45a79f398363da \ No newline at end of file +03d8362cd2cadab8e1cc5b18a3194152f2bd0a84 \ No newline at end of file diff --git a/src/os.h b/src/os.h index 80afc516ff..52ac4b0cbc 100644 --- a/src/os.h +++ b/src/os.h @@ -119,7 +119,7 @@ ** The default size of a disk sector */ #ifndef SQLITE_DEFAULT_SECTOR_SIZE -# define SQLITE_DEFAULT_SECTOR_SIZE 512 +# define SQLITE_DEFAULT_SECTOR_SIZE 4096 #endif /* diff --git a/src/os_unix.c b/src/os_unix.c index adf11541ff..6542c0e66c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -122,9 +122,6 @@ #ifndef SQLITE_OMIT_WAL #include #endif -#ifndef MISSING_STATVFS -#include -#endif #if SQLITE_ENABLE_LOCKING_STYLE @@ -215,7 +212,6 @@ struct unixFile { int h; /* The file descriptor */ unsigned char eFileLock; /* The type of lock held on this fd */ unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ - unsigned char szSector; /* Sectorsize/512 */ int lastErrno; /* The unix errno from last I/O error */ void *lockingContext; /* Locking style specific state */ UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ @@ -420,14 +416,6 @@ static struct unix_syscall { { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) -#if defined(MISSING_STATVFS) - { "statvfs", (sqlite3_syscall_ptr)0, 0 }, -#define osStatvfs ((int(*)(const char*,void*))aSyscall[20].pCurrent) -#else - { "statvfs", (sqlite3_syscall_ptr)statvfs, 0 }, -#define osStatvfs ((int(*)(const char*,struct statvfs*))aSyscall[20].pCurrent) -#endif - }; /* End of the overrideable system calls */ /* @@ -3600,23 +3588,8 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ ** same for both. */ static int unixSectorSize(sqlite3_file *pFile){ - unixFile *p = (unixFile*)pFile; - if( p->szSector==0 ){ -#ifdef MISSING_STATVFS - p->szSector = SQLITE_DEFAULT_SECTOR_SIZE/512; -#else - struct statvfs x; - int sz; - memset(&x, 0, sizeof(x)); - osStatvfs(p->zPath, &x); - sz = (int)x.f_frsize; - if( sz<512 || sz>65536 || (sz&(sz-1))!=0 ){ - sz = SQLITE_DEFAULT_SECTOR_SIZE; - } - p->szSector = sz/512; -#endif - } - return p->szSector*512; + (void)pFile; + return SQLITE_DEFAULT_SECTOR_SIZE; } /* @@ -6833,7 +6806,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==21 ); + assert( ArraySize(aSyscall)==20 ); /* Register all VFSes defined in the aVfs[] array */ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ diff --git a/src/os_win.c b/src/os_win.c index 18fdd93933..9ced7baaf0 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -61,7 +61,6 @@ struct winFile { short sharedLockByte; /* Randomly chosen byte used as a shared lock */ u8 ctrlFlags; /* Flags. See WINFILE_* below */ DWORD lastErrno; /* The Windows errno from the last I/O error */ - DWORD sectorSize; /* Sector size of the device file is on */ winShm *pShm; /* Instance of shared memory on this file */ const char *zPath; /* Full pathname of this file */ int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ @@ -151,14 +150,6 @@ static void winMemShutdown(void *pAppData); const sqlite3_mem_methods *sqlite3MemGetWin32(void); #endif /* SQLITE_WIN32_MALLOC */ -/* -** Forward prototypes. -*/ -static int getSectorSize( - sqlite3_vfs *pVfs, - const char *zRelative /* UTF-8 file name */ -); - /* ** The following variable is (normally) set once and never changes ** thereafter. It records whether the operating system is Win9x @@ -2225,8 +2216,8 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ ** same for both. */ static int winSectorSize(sqlite3_file *id){ - assert( id!=0 ); - return (int)(((winFile*)id)->sectorSize); + (void)id; + return SQLITE_DEFAULT_SECTOR_SIZE; } /* @@ -3203,7 +3194,6 @@ static int winOpen( if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ pFile->ctrlFlags |= WINFILE_PSOW; } - pFile->sectorSize = getSectorSize(pVfs, zUtf8Name); #if SQLITE_OS_WINCE if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB @@ -3448,81 +3438,6 @@ static int winFullPathname( #endif } -/* -** Get the sector size of the device used to store -** file. -*/ -static int getSectorSize( - sqlite3_vfs *pVfs, - const char *zRelative /* UTF-8 file name */ -){ - DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; - /* GetDiskFreeSpace is not supported under WINCE */ -#if SQLITE_OS_WINCE - UNUSED_PARAMETER(pVfs); - UNUSED_PARAMETER(zRelative); -#else - char zFullpath[MAX_PATH+1]; - int rc; - DWORD dwRet = 0; - DWORD dwDummy; - - /* - ** We need to get the full path name of the file - ** to get the drive letter to look up the sector - ** size. - */ - SimulateIOErrorBenign(1); - sqlite3BeginBenignMalloc(); - rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath); - sqlite3EndBenignMalloc(); - SimulateIOErrorBenign(0); - if( rc == SQLITE_OK ) - { - void *zConverted; - sqlite3BeginBenignMalloc(); - zConverted = convertUtf8Filename(zFullpath); - sqlite3EndBenignMalloc(); - if( zConverted ){ - if( isNT() ){ - /* trim path to just drive reference */ - LPWSTR p = zConverted; - for(;*p;p++){ - if( *p == '\\' ){ - *p = '\0'; - break; - } - } - dwRet = osGetDiskFreeSpaceW((LPCWSTR)zConverted, - &dwDummy, - &bytesPerSector, - &dwDummy, - &dwDummy); - }else{ - /* trim path to just drive reference */ - char *p = (char *)zConverted; - for(;*p;p++){ - if( *p == '\\' ){ - *p = '\0'; - break; - } - } - dwRet = osGetDiskFreeSpaceA((char*)zConverted, - &dwDummy, - &bytesPerSector, - &dwDummy, - &dwDummy); - } - sqlite3_free(zConverted); - } - if( !dwRet ){ - bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; - } - } -#endif - return (int) bytesPerSector; -} - #ifndef SQLITE_OMIT_LOAD_EXTENSION /* ** Interfaces for opening a shared library, finding entry points