]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Move the os_unix.c file closer to trunk.
authordrh <drh@noemail.net>
Thu, 19 Feb 2015 02:43:19 +0000 (02:43 +0000)
committerdrh <drh@noemail.net>
Thu, 19 Feb 2015 02:43:19 +0000 (02:43 +0000)
FossilOrigin-Name: 57d7024007c2a71bf6cb875b1f1daf26924d188e

manifest
manifest.uuid
src/os_unix.c

index a997a4c2fc8c2a90ce01ee3efd0d5e0808514006..8a4d8c6eb7e3f49ffc3a251447777c5ed0743f1a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhancements\sto\sSQLITE_ENABLE_API_ARMOR\smerged\sfrom\strunk.
-D 2015-02-13T16:42:49.659
+C Move\sthe\sos_unix.c\sfile\scloser\sto\strunk.
+D 2015-02-19T02:43:19.628
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e1f1fce0d47e29ffae67c92834d0e6e1c699743e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -217,7 +217,7 @@ F src/os.c 5822c2b843a77219bba1e28887cdc816b27ca29d
 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
-F src/os_unix.c 06e10d7aaf6b06947d9da35b38ff05000bf5058f
+F src/os_unix.c 56b0830336d47860be19610d057548c6303733c8
 F src/os_win.c 1d1ef630b3e3859b7399952909e10d3a4d43fc77
 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
 F src/pager.c 694caffb16891a96608193968d7c9a8fa9a71240
@@ -1244,7 +1244,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P b2449d67768f4d3d83877d9c45e5b4b17bb6a551 823ad40ccb5b51aaa0d5a48da63b465df9d0649a
-R 34fbf0e66795550d51489fb09903ffef
+P 5147b94ae6dc3e1bae5c506563347880c3a302b1
+R 6b3cfa6d91c403080a3780789432dd25
 U drh
-Z ba17bdddc836de1631382089bbd63eae
+Z 90d307cc802c08c29ee77dea9a89c868
index 75129c4e563c4b7affaf245a473d6bc744691ddf..c00c40037e26182c5e86c33f2d1a7ddebe204101 100644 (file)
@@ -1 +1 @@
-5147b94ae6dc3e1bae5c506563347880c3a302b1
\ No newline at end of file
+57d7024007c2a71bf6cb875b1f1daf26924d188e
\ No newline at end of file
index 299f5a30b1975d46fc59eb1bb67c5c9a25bef96e..5b5b83e743e668d7a51e88b5dff88d52506c8d8b 100644 (file)
@@ -46,9 +46,6 @@
 #include "sqliteInt.h"
 #if SQLITE_OS_UNIX              /* This file is used on unix only */
 
-#include "btreeInt.h"           /* Use by Apple extensions only */
-
-
 /*
 ** There are various methods for file locking used for concurrency
 ** control:
 #if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
 # include <sys/ioctl.h>
 # include <uuid/uuid.h>
-# if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
-                            (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
-#  define HAVE_GETHOSTUUID 1
-# endif
 # if OS_VXWORKS
 #  include <semaphore.h>
 #  include <limits.h>
@@ -1473,6 +1466,10 @@ static void robust_close(unixFile *pFile, int h, int lineno){
   }
 }
 
+/*
+** Set the pFile->lastErrno.  Do this in a subroutine as that provides a convenient
+** place to set a breakpoint.
+*/
 static void storeLastErrno(unixFile *pFile, int error){
   pFile->lastErrno = error;
 }
@@ -1671,7 +1668,7 @@ static void verifyDbFile(unixFile *pFile){
     return;
   }
   if( fileHasMoved(pFile) ){
-    sqlite3_log(SQLITE_WARNING, "file renamed while open: [%s]", pFile->zPath);
+    sqlite3_log(SQLITE_WARNING, "file renamed while open: %s", pFile->zPath);
     pFile->ctrlFlags |= UNIXFILE_WARNED;
     return;
   }
@@ -2384,15 +2381,15 @@ static int nolockClose(sqlite3_file *id) {
   unixEnterMutex();
   
   /* unixFile.pInode is always valid here. Otherwise, a different close
-   ** routine (e.g. nolockClose()) would be called instead.
-   */
+  ** routine (e.g. nolockClose()) would be called instead.
+  */
   assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );
   if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){
     /* If there are outstanding locks, do not actually close the file just
-     ** yet because that would clear those locks.  Instead, add the file
-     ** descriptor to pInode->pUnused list.  It will be automatically closed 
-     ** when the last lock is cleared.
-     */
+    ** yet because that would clear those locks.  Instead, add the file
+    ** descriptor to pInode->pUnused list.  It will be automatically closed 
+    ** when the last lock is cleared.
+    */
     setPendingFd(pFile);
   }
   releaseInodeInfo(pFile);
@@ -3613,6 +3610,7 @@ static int unixRead(
     /* lastErrno set by seekAndRead */
     return SQLITE_IOERR_READ;
   }else{
+    storeLastErrno(pFile, 0);   /* not a system error */
     /* Unread parts of the buffer must be zero-filled */
     memset(&((char*)pBuf)[got], 0, amt-got);
     return SQLITE_IOERR_SHORT_READ;
@@ -3753,6 +3751,7 @@ static int unixWrite(
       /* lastErrno set by seekAndWrite */
       return SQLITE_IOERR_WRITE;
     }else{
+      storeLastErrno(pFile, 0); /* not a system error */
       return SQLITE_FULL;
     }
   }
@@ -4158,7 +4157,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
     int rc;
     if( pFile->szChunk<=0 ){
       if( robust_ftruncate(pFile->h, nByte) ){
-        pFile->lastErrno = errno;
+        storeLastErrno(pFile, errno);
         return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
       }
     }
@@ -4175,7 +4174,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
 #if (SQLITE_ENABLE_APPLE_SPI>0) && defined(__APPLE__)
 #include "sqlite3_private.h"
 #include <copyfile.h>
-static int getDbPathForUnixFile(unixFile *pFile, char *dbPath);
+static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath);
 #endif
 
 #if SQLITE_ENABLE_LOCKING_STYLE
@@ -5001,7 +5000,9 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
   pShmNode = pInode->pShmNode;
   if( pShmNode==0 ){
     struct stat sStat;                 /* fstat() info for database file */
+#ifndef SQLITE_SHM_DIRECTORY
     const char *zBasePath = pDbFd->zPath;
+#endif
 
     /* Call fstat() to figure out the permissions on the database file. If
     ** a new *-shm file is created, an attempt will be made to create it
@@ -5013,10 +5014,11 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
       goto shm_open_err;
     }
 
-#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
+#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE \
+      && !defined(SQLITE_SHM_DIRECTORY)
     /* If pDbFd is configured with proxy locking mode, use the local 
-     ** lock file path to determine the -shm file path
-     */
+    ** lock file path to determine the -shm file path
+    */
     if( isProxyLockingMode(pDbFd) ){
       zBasePath = proxySharedMemoryBasePath(pDbFd);
       if( !zBasePath ){
@@ -5446,7 +5448,7 @@ static int unixShmUnmap(
   if( pShmNode->nRef==0 ){
     if( deleteFlag && pShmNode->h>=0 ) {
       if (deleteFlag == 1) { 
-        unlink(pShmNode->zFilename);
+        osUnlink(pShmNode->zFilename);
       } else if (deleteFlag == 2) {
         /* ftruncate(pShmNode->h, 32 * 1024); */
       }
@@ -6566,7 +6568,7 @@ static int fillInUnixFile(
   }
 #endif
   
-  pNew->lastErrno = 0;
+  storeLastErrno(pNew, 0);
 #if OS_VXWORKS
   if( rc!=SQLITE_OK ){
     if( h>=0 ) robust_close(pNew, h, __LINE__);
@@ -7500,9 +7502,10 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){
 **
 ** C APIs
 **
-**  sqlite3_file_control(db, dbname, SQLITE_SET_LOCKPROXYFILE,
+**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE,
 **                       <proxy_path> | ":auto:");
-**  sqlite3_file_control(db, dbname, SQLITE_GET_LOCKPROXYFILE, &<proxy_path>);
+**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,
+**                       &<proxy_path>);
 **
 **
 ** SQL pragmas
@@ -7595,7 +7598,7 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){
 ** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will
 ** force proxy locking to be used for every database file opened, and 0
 ** will force automatic proxy locking to be disabled for all database
-** files (explicitly calling the SQLITE_SET_LOCKPROXYFILE pragma or
+** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or
 ** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).
 */
 
@@ -7832,10 +7835,10 @@ extern int gethostuuid(uuid_t id, const struct timespec *wait);
 static int proxyGetHostID(unsigned char *pHostID, int *pError){
   assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
   memset(pHostID, 0, PROXY_HOSTIDLEN);
-#if HAVE_GETHOSTUUID
+# if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
+                            (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
   {
     struct timespec timeout = {1, 0}; /* 1 sec timeout */
-    
     if( gethostuuid(pHostID, &timeout) ){
       int err = errno;
       if( pError ){
@@ -8354,7 +8357,7 @@ static int switchLockProxyPath(unixFile *pFile, const char *path) {
 ** This routine find the filename associated with pFile and writes it
 ** int dbPath.
 */
-static int getDbPathForUnixFile(unixFile *pFile, char *dbPath){
+static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){
 #if defined(__APPLE__)
   if( pFile->pMethod == &afpIoMethods ){
     /* afp style keeps a reference to the db path in the filePath field 
@@ -8394,7 +8397,7 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
   if( pFile->eFileLock!=NO_LOCK ){
     return SQLITE_BUSY;
   }
-  getDbPathForUnixFile(pFile, dbPath);
+  proxyGetDbPathForUnixFile(pFile, dbPath);
   if( !path || path[0]=='\0' || !strcmp(path, ":auto:") ){
     lockPath=NULL;
   }else{
@@ -8477,7 +8480,7 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
 */
 static int proxyFileControl(sqlite3_file *id, int op, void *pArg){
   switch( op ){
-    case SQLITE_GET_LOCKPROXYFILE: {
+    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {
       unixFile *pFile = (unixFile*)id;
       if( isProxyLockingMode(pFile) ){
         proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;
@@ -8492,7 +8495,7 @@ static int proxyFileControl(sqlite3_file *id, int op, void *pArg){
       }
       return SQLITE_OK;
     }
-    case SQLITE_SET_LOCKPROXYFILE: {
+    case SQLITE_FCNTL_SET_LOCKPROXYFILE: {
       unixFile *pFile = (unixFile*)id;
       int rc = SQLITE_OK;
       int isProxyStyle = isProxyLockingMode(pFile);