/ Check-in [7b6e30e6]
Login

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

Overview
Comment:Log all error from close() in os_unix.c to sqlite3_log() but do not attempt to report errors back up to the application. Update the unix error logging to put the most important information earlier in the message.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7b6e30e6a712311d4ef275253b085b85e6e17116
User & Date: drh 2011-03-02 02:08:13
References
2011-03-02
17:54
Fix bugs in [7b6e30e6a7] that only show up on Mac. check-in: ec55e8c6 user: drh tags: trunk
Context
2011-03-02
15:44
Make sure the rtreenode() testing and analysis routine in the RTREE extension can handle 64-bit rowids. This fix is in response to a message on the mailing list. check-in: 24602557 user: drh tags: trunk
15:09
Proof-of-concept prototype for the proposed xSetSystemCall extension method on the VFS. check-in: 92b5a76a user: drh tags: syscall-override
02:08
Log all error from close() in os_unix.c to sqlite3_log() but do not attempt to report errors back up to the application. Update the unix error logging to put the most important information earlier in the message. check-in: 7b6e30e6 user: drh tags: trunk
2011-02-25
03:25
Comment out some code in os_unix.c that only runs on MacOSX with SQLITE_ENABLE_LOCKING_STYLE. check-in: 4e50b036 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   763    763   **
   764    764   ** The first argument passed to the macro should be the error code that
   765    765   ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). 
   766    766   ** The two subsequent arguments should be the name of the OS function that
   767    767   ** failed (e.g. "unlink", "open") and the the associated file-system path,
   768    768   ** if any.
   769    769   */
   770         -#define unixLogError(a,b,c)     unixLogError_x(a,b,c,__LINE__)
   771         -static int unixLogError_x(
          770  +#define unixLogError(a,b,c)     unixLogErrorAtLine(a,b,c,__LINE__)
          771  +static int unixLogErrorAtLine(
   772    772     int errcode,                    /* SQLite error code */
   773    773     const char *zFunc,              /* Name of OS function that failed */
   774    774     const char *zPath,              /* File path associated with error */
   775    775     int iLine                       /* Source line number where error occurred */
   776    776   ){
   777    777     char *zErr;                     /* Message from strerror() or equivalent */
          778  +  int iErrno = errno;             /* Saved syscall error number */
   778    779   
   779    780     /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use
   780    781     ** the strerror() function to obtain the human-readable error message
   781    782     ** equivalent to errno. Otherwise, use strerror_r().
   782    783     */ 
   783    784   #if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)
   784    785     char aErr[80];
................................................................................
   796    797     ** available, the error message will often be an empty string. Not a
   797    798     ** huge problem. Incorrectly concluding that the GNU version is available 
   798    799     ** could lead to a segfault though.
   799    800     */
   800    801   #if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)
   801    802     zErr = 
   802    803   # endif
   803         -  strerror_r(errno, aErr, sizeof(aErr)-1);
          804  +  strerror_r(iErrno, aErr, sizeof(aErr)-1);
   804    805   
   805    806   #elif SQLITE_THREADSAFE
   806    807     /* This is a threadsafe build, but strerror_r() is not available. */
   807    808     zErr = "";
   808    809   #else
   809    810     /* Non-threadsafe build, use strerror(). */
   810         -  zErr = strerror(errno);
          811  +  zErr = strerror(iErrno);
   811    812   #endif
   812    813   
   813    814     assert( errcode!=SQLITE_OK );
          815  +  if( zPath==0 ) zPath = "";
   814    816     sqlite3_log(errcode,
   815         -      "os_unix.c: %s() at line %d - \"%s\" errno=%d path=%s",
   816         -      zFunc, iLine, zErr, errno, (zPath ? zPath : "n/a")
          817  +      "os_unix.c:%d: (%d) %s(%s) - %s",
          818  +      iLine, iErrno, zFunc, zPath, zErr
   817    819     );
   818    820   
   819    821     return errcode;
   820    822   }
   821    823   
          824  +/*
          825  +** Close a file descriptor.
          826  +**
          827  +** We assume that close() almost always works, since it is only in a
          828  +** very sick application or on a very sick platform that it might fail.
          829  +** If it does fail, simply leak the file descriptor, but do log the
          830  +** error.
          831  +**
          832  +** Note that it is not safe to retry close() after EINTR since the
          833  +** file descriptor might have already been reused by another thread.
          834  +** So we don't even try to recover from an EINTR.  Just log the error
          835  +** and move on.
          836  +*/
          837  +static void robust_close(unixFile *pFile, int h, int lineno){
          838  +  if( close(h) ){
          839  +    unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
          840  +                       pFile ? pFile->zPath : 0, lineno);
          841  +  }
          842  +}
   822    843   
   823    844   /*
   824    845   ** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.
   825         -** If all such file descriptors are closed without error, the list is
   826         -** cleared and SQLITE_OK returned.
   827         -**
   828         -** Otherwise, if an error occurs, then successfully closed file descriptor
   829         -** entries are removed from the list, and SQLITE_IOERR_CLOSE returned. 
   830         -** not deleted and SQLITE_IOERR_CLOSE returned.
   831    846   */ 
   832         -static int closePendingFds(unixFile *pFile){
   833         -  int rc = SQLITE_OK;
          847  +static void closePendingFds(unixFile *pFile){
   834    848     unixInodeInfo *pInode = pFile->pInode;
   835         -  UnixUnusedFd *pError = 0;
   836    849     UnixUnusedFd *p;
   837    850     UnixUnusedFd *pNext;
   838    851     for(p=pInode->pUnused; p; p=pNext){
   839    852       pNext = p->pNext;
   840         -    if( close(p->fd) ){
   841         -      pFile->lastErrno = errno;
   842         -      rc = unixLogError(SQLITE_IOERR_CLOSE, "close", pFile->zPath);
   843         -      p->pNext = pError;
   844         -      pError = p;
   845         -    }else{
   846         -      sqlite3_free(p);
   847         -    }
          853  +    robust_close(pFile, p->fd, __LINE__);
          854  +    sqlite3_free(p);
   848    855     }
   849         -  pInode->pUnused = pError;
   850         -  return rc;
          856  +  pInode->pUnused = 0;
   851    857   }
   852    858   
   853    859   /*
   854    860   ** Release a unixInodeInfo structure previously allocated by findInodeInfo().
   855    861   **
   856    862   ** The mutex entered using the unixEnterMutex() function must be held
   857    863   ** when this function is called.
................................................................................
  1454   1460       /* Decrement the count of locks against this same file.  When the
  1455   1461       ** count reaches zero, close any other file descriptors whose close
  1456   1462       ** was deferred because of outstanding locks.
  1457   1463       */
  1458   1464       pInode->nLock--;
  1459   1465       assert( pInode->nLock>=0 );
  1460   1466       if( pInode->nLock==0 ){
  1461         -      int rc2 = closePendingFds(pFile);
  1462         -      if( rc==SQLITE_OK ){
  1463         -        rc = rc2;
  1464         -      }
         1467  +      closePendingFds(pFile);
  1465   1468       }
  1466   1469     }
  1467   1470   	
  1468   1471   end_unlock:
  1469   1472     unixLeaveMutex();
  1470   1473     if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;
  1471   1474     return rc;
................................................................................
  1492   1495   ** even on VxWorks.  A mutex will be acquired on VxWorks by the
  1493   1496   ** vxworksReleaseFileId() routine.
  1494   1497   */
  1495   1498   static int closeUnixFile(sqlite3_file *id){
  1496   1499     unixFile *pFile = (unixFile*)id;
  1497   1500     if( pFile ){
  1498   1501       if( pFile->dirfd>=0 ){
  1499         -      int err = close(pFile->dirfd);
  1500         -      if( err ){
  1501         -        pFile->lastErrno = errno;
  1502         -        return unixLogError(SQLITE_IOERR_DIR_CLOSE, "close", pFile->zPath);
  1503         -      }else{
  1504         -        pFile->dirfd=-1;
  1505         -      }
         1502  +      robust_close(pFile, pFile->dirfd, __LINE__);
         1503  +      pFile->dirfd=-1;
  1506   1504       }
  1507   1505       if( pFile->h>=0 ){
  1508         -      int err = close(pFile->h);
  1509         -      if( err ){
  1510         -        pFile->lastErrno = errno;
  1511         -        return unixLogError(SQLITE_IOERR_CLOSE, "close", pFile->zPath);
  1512         -      }
         1506  +      robust_close(pFile, pFile->h, __LINE__);
         1507  +      pFile->h = -1;
  1513   1508       }
  1514   1509   #if OS_VXWORKS
  1515   1510       if( pFile->pId ){
  1516   1511         if( pFile->isDelete ){
  1517   1512           unlink(pFile->pId->zCanonicalName);
  1518   1513         }
  1519   1514         vxworksReleaseFileId(pFile->pId);
................................................................................
  1715   1710         rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
  1716   1711         if( IS_LOCK_ERROR(rc) ){
  1717   1712           pFile->lastErrno = tErrno;
  1718   1713         }
  1719   1714       }
  1720   1715       return rc;
  1721   1716     } 
  1722         -  if( close(fd) ){
  1723         -    pFile->lastErrno = errno;
  1724         -    rc = SQLITE_IOERR_CLOSE;
  1725         -  }
         1717  +  robust_close(pFile, fd, __LINE__);
  1726   1718     
  1727   1719     /* got it, set the type and return ok */
  1728   1720     pFile->eFileLock = eFileLock;
  1729   1721     return rc;
  1730   1722   }
  1731   1723   
  1732   1724   /*
................................................................................
  2610   2602           pFile->eFileLock = NO_LOCK;
  2611   2603         }
  2612   2604       }
  2613   2605       if( rc==SQLITE_OK ){
  2614   2606         pInode->nLock--;
  2615   2607         assert( pInode->nLock>=0 );
  2616   2608         if( pInode->nLock==0 ){
  2617         -        rc = closePendingFds(pFile);
         2609  +        closePendingFds(pFile);
  2618   2610         }
  2619   2611       }
  2620   2612     }
  2621   2613     
  2622   2614     unixLeaveMutex();
  2623   2615     if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;
  2624   2616     return rc;
................................................................................
  3043   3035     rc = full_fsync(pFile->h, isFullsync, isDataOnly);
  3044   3036     SimulateIOError( rc=1 );
  3045   3037     if( rc ){
  3046   3038       pFile->lastErrno = errno;
  3047   3039       return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath);
  3048   3040     }
  3049   3041     if( pFile->dirfd>=0 ){
  3050         -    int err;
  3051   3042       OSTRACE(("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
  3052   3043               HAVE_FULLFSYNC, isFullsync));
  3053   3044   #ifndef SQLITE_DISABLE_DIRSYNC
  3054   3045       /* The directory sync is only attempted if full_fsync is
  3055   3046       ** turned off or unavailable.  If a full_fsync occurred above,
  3056   3047       ** then the directory sync is superfluous.
  3057   3048       */
................................................................................
  3062   3053          ** A failed directory sync is not a big deal.  So it seems
  3063   3054          ** better to ignore the error.  Ticket #1657
  3064   3055          */
  3065   3056          /* pFile->lastErrno = errno; */
  3066   3057          /* return SQLITE_IOERR; */
  3067   3058       }
  3068   3059   #endif
  3069         -    err = close(pFile->dirfd); /* Only need to sync once, so close the */
  3070         -    if( err==0 ){              /* directory when we are done */
  3071         -      pFile->dirfd = -1;
  3072         -    }else{
  3073         -      pFile->lastErrno = errno;
  3074         -      rc = unixLogError(SQLITE_IOERR_DIR_CLOSE, "close", pFile->zPath);
  3075         -    }
         3060  +    /* Only need to sync once, so close the  directory when we are done */
         3061  +    robust_close(pFile, pFile->dirfd, __LINE__);
         3062  +    pFile->dirfd = -1;
  3076   3063     }
  3077   3064     return rc;
  3078   3065   }
  3079   3066   
  3080   3067   /*
  3081   3068   ** Truncate an open file to a specified size
  3082   3069   */
................................................................................
  3435   3422       int i;
  3436   3423       assert( p->pInode==pFd->pInode );
  3437   3424       if( p->mutex ) sqlite3_mutex_free(p->mutex);
  3438   3425       for(i=0; i<p->nRegion; i++){
  3439   3426         munmap(p->apRegion[i], p->szRegion);
  3440   3427       }
  3441   3428       sqlite3_free(p->apRegion);
  3442         -    if( p->h>=0 ) close(p->h);
         3429  +    if( p->h>=0 ){
         3430  +      robust_close(pFd, p->h, __LINE__);
         3431  +      p->h = -1;
         3432  +    }
  3443   3433       p->pInode->pShmNode = 0;
  3444   3434       sqlite3_free(p);
  3445   3435     }
  3446   3436   }
  3447   3437   
  3448   3438   /*
  3449   3439   ** Open a shared-memory area associated with open database file pDbFd.  
................................................................................
  4246   4236         ** handle h - as it is guaranteed that no posix locks will be released
  4247   4237         ** by doing so.
  4248   4238         **
  4249   4239         ** If scenario (a) caused the error then things are not so safe. The
  4250   4240         ** implicit assumption here is that if fstat() fails, things are in
  4251   4241         ** such bad shape that dropping a lock or two doesn't matter much.
  4252   4242         */
  4253         -      close(h);
         4243  +      robust_close(pNew, h, __LINE__);
  4254   4244         h = -1;
  4255   4245       }
  4256   4246       unixLeaveMutex();
  4257   4247     }
  4258   4248   
  4259   4249   #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
  4260   4250     else if( pLockingStyle == &afpIoMethods ){
................................................................................
  4272   4262         pCtx->dbPath = zFilename;
  4273   4263         pCtx->reserved = 0;
  4274   4264         srandomdev();
  4275   4265         unixEnterMutex();
  4276   4266         rc = findInodeInfo(pNew, &pNew->pInode);
  4277   4267         if( rc!=SQLITE_OK ){
  4278   4268           sqlite3_free(pNew->lockingContext);
  4279         -        close(h);
         4269  +        robust_close(pNew, h, __LINE__);
  4280   4270           h = -1;
  4281   4271         }
  4282   4272         unixLeaveMutex();        
  4283   4273       }
  4284   4274     }
  4285   4275   #endif
  4286   4276   
................................................................................
  4323   4313       unixLeaveMutex();
  4324   4314     }
  4325   4315   #endif
  4326   4316     
  4327   4317     pNew->lastErrno = 0;
  4328   4318   #if OS_VXWORKS
  4329   4319     if( rc!=SQLITE_OK ){
  4330         -    if( h>=0 ) close(h);
         4320  +    if( h>=0 ) robust_close(pNew, h, __LINE__);
  4331   4321       h = -1;
  4332   4322       unlink(zFilename);
  4333   4323       isDelete = 0;
  4334   4324     }
  4335   4325     pNew->isDelete = isDelete;
  4336   4326   #endif
  4337   4327     if( rc!=SQLITE_OK ){
  4338         -    if( dirfd>=0 ) close(dirfd); /* silent leak if fail, already in error */
  4339         -    if( h>=0 ) close(h);
         4328  +    if( dirfd>=0 ) robust_close(pNew, dirfd, __LINE__);
         4329  +    if( h>=0 ) robust_close(pNew, h, __LINE__);
  4340   4330     }else{
  4341   4331       pNew->pMethod = pLockingStyle;
  4342   4332       OpenCounter(+1);
  4343   4333     }
  4344   4334     return rc;
  4345   4335   }
  4346   4336   
................................................................................
  4744   4734       rc = openDirectory(zPath, &dirfd);
  4745   4735       if( rc!=SQLITE_OK ){
  4746   4736         /* It is safe to close fd at this point, because it is guaranteed not
  4747   4737         ** to be open on a database file. If it were open on a database file,
  4748   4738         ** it would not be safe to close as this would release any locks held
  4749   4739         ** on the file by this process.  */
  4750   4740         assert( eType!=SQLITE_OPEN_MAIN_DB );
  4751         -      close(fd);             /* silently leak if fail, already in error */
         4741  +      robust_close(p, fd, __LINE__);
  4752   4742         goto open_finished;
  4753   4743       }
  4754   4744     }
  4755   4745   
  4756   4746   #ifdef FD_CLOEXEC
  4757   4747     fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
  4758   4748   #endif
................................................................................
  4760   4750     noLock = eType!=SQLITE_OPEN_MAIN_DB;
  4761   4751   
  4762   4752     
  4763   4753   #if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
  4764   4754     struct statfs fsInfo;
  4765   4755     if( fstatfs(fd, &fsInfo) == -1 ){
  4766   4756       ((unixFile*)pFile)->lastErrno = errno;
  4767         -    if( dirfd>=0 ) close(dirfd); /* silently leak if fail, in error */
  4768         -    close(fd); /* silently leak if fail, in error */
         4757  +    if( dirfd>=0 ) robust_close(p, dirfd, __LINE__);
         4758  +    robust_close(p, fd, __LINE__);
  4769   4759       return SQLITE_IOERR_ACCESS;
  4770   4760     }
  4771   4761     if (0 == strncmp("msdos", fsInfo.f_fstypename, 5)) {
  4772   4762       ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;
  4773   4763     }
  4774   4764   #endif
  4775   4765     
................................................................................
  4793   4783           ** on that file that are currently holding advisory locks on it,
  4794   4784           ** then the call to close() will cancel those locks. In practice,
  4795   4785           ** we're assuming that statfs() doesn't fail very often. At least
  4796   4786           ** not while other file descriptors opened by the same process on
  4797   4787           ** the same file are working.  */
  4798   4788           p->lastErrno = errno;
  4799   4789           if( dirfd>=0 ){
  4800         -          close(dirfd); /* silently leak if fail, in error */
         4790  +          robust_close(p, dirfd, __LINE__);
  4801   4791           }
  4802         -        close(fd); /* silently leak if fail, in error */
         4792  +        robust_close(p, fd, __LINE__);
  4803   4793           rc = SQLITE_IOERR_ACCESS;
  4804   4794           goto open_finished;
  4805   4795         }
  4806   4796         useProxy = !(fsInfo.f_flags&MNT_LOCAL);
  4807   4797       }
  4808   4798       if( useProxy ){
  4809   4799         rc = fillInUnixFile(pVfs, fd, dirfd, pFile, zPath, noLock, isDelete);
................................................................................
  4856   4846         if( fsync(fd)==-1 )
  4857   4847   #else
  4858   4848         if( fsync(fd) )
  4859   4849   #endif
  4860   4850         {
  4861   4851           rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, "fsync", zPath);
  4862   4852         }
  4863         -      if( close(fd)&&!rc ){
  4864         -        rc = unixLogError(SQLITE_IOERR_DIR_CLOSE, "close", zPath);
  4865         -      }
         4853  +      robust_close(0, fd, __LINE__);
  4866   4854       }
  4867   4855     }
  4868   4856   #endif
  4869   4857     return rc;
  4870   4858   }
  4871   4859   
  4872   4860   /*
................................................................................
  5046   5034         memcpy(zBuf, &t, sizeof(t));
  5047   5035         pid = getpid();
  5048   5036         memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
  5049   5037         assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf );
  5050   5038         nBuf = sizeof(t) + sizeof(pid);
  5051   5039       }else{
  5052   5040         do{ nBuf = read(fd, zBuf, nBuf); }while( nBuf<0 && errno==EINTR );
  5053         -      close(fd);
         5041  +      robust_close(0, fd, __LINE__);
  5054   5042       }
  5055   5043     }
  5056   5044   #endif
  5057   5045     return nBuf;
  5058   5046   }
  5059   5047   
  5060   5048   
................................................................................
  5489   5477     
  5490   5478     rc = fillInUnixFile(&dummyVfs, fd, dirfd, (sqlite3_file*)pNew, path, 0, 0);
  5491   5479     if( rc==SQLITE_OK ){
  5492   5480       *ppFile = pNew;
  5493   5481       return SQLITE_OK;
  5494   5482     }
  5495   5483   end_create_proxy:    
  5496         -  close(fd); /* silently leak fd if error, we're already in error */
         5484  +  robust_close(pNew, fd, __LINE__);
  5497   5485     sqlite3_free(pNew);
  5498   5486     sqlite3_free(pUnused);
  5499   5487     return rc;
  5500   5488   }
  5501   5489   
  5502   5490   #ifdef SQLITE_TEST
  5503   5491   /* simulate multiple hosts by creating unique hostid file paths */
................................................................................
  5589   5577     }
  5590   5578     if( rename(tPath, cPath) ){
  5591   5579       sqlite3_snprintf(sizeof(errmsg), errmsg, "rename failed (%d)", errno);
  5592   5580       goto end_breaklock;
  5593   5581     }
  5594   5582     rc = 0;
  5595   5583     fprintf(stderr, "broke stale lock on %s\n", cPath);
  5596         -  close(conchFile->h);
         5584  +  robust_close(pFile, conchFile->h, __LINE__);
  5597   5585     conchFile->h = fd;
  5598   5586     conchFile->openFlags = O_RDWR | O_CREAT;
  5599   5587   
  5600   5588   end_breaklock:
  5601   5589     if( rc ){
  5602   5590       if( fd>=0 ){
  5603   5591         unlink(tPath);
  5604         -      close(fd);
         5592  +      robust_close(pFile, fd, __LINE__);
  5605   5593       }
  5606   5594       fprintf(stderr, "failed to break stale lock on %s, %s\n", cPath, errmsg);
  5607   5595     }
  5608   5596     return rc;
  5609   5597   }
  5610   5598   
  5611   5599   /* Take the requested lock on the conch file and break a stale lock if the 
................................................................................
  5847   5835         }
  5848   5836         conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, SHARED_LOCK);
  5849   5837         
  5850   5838       end_takeconch:
  5851   5839         OSTRACE(("TRANSPROXY: CLOSE  %d\n", pFile->h));
  5852   5840         if( rc==SQLITE_OK && pFile->openFlags ){
  5853   5841           if( pFile->h>=0 ){
  5854         -#ifdef STRICT_CLOSE_ERROR
  5855         -          if( close(pFile->h) ){
  5856         -            pFile->lastErrno = errno;
  5857         -            return SQLITE_IOERR_CLOSE;
  5858         -          }
  5859         -#else
  5860         -          close(pFile->h); /* silently leak fd if fail */
  5861         -#endif
         5842  +          robust_close(pFile, pFile->h, __LINE__) ){
  5862   5843           }
  5863   5844           pFile->h = -1;
  5864   5845           int fd = open(pCtx->dbPath, pFile->openFlags,
  5865   5846                         SQLITE_DEFAULT_FILE_PERMISSIONS);
  5866   5847           OSTRACE(("TRANSPROXY: OPEN  %d\n", fd));
  5867   5848           if( fd>=0 ){
  5868   5849             pFile->h = fd;

Changes to test/oserror.test.

    52     52       for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
    53     53     } msg] $msg
    54     54   } {1 {unable to open database file}}
    55     55   do_test 1.1.2 {
    56     56     catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
    57     57   } {1}
    58     58   
    59         -do_re_test 1.1.3 { lindex $::log 0 } {^os_unix.c: open.*test.db$}
           59  +do_re_test 1.1.3 { lindex $::log 0 } {^os_unix.c:\d*: \(24\) open\(.*test.db\) - }
    60     60   
    61     61   
    62     62   # Test a failure in open() due to the path being a directory.
    63     63   #
    64     64   do_test 1.2.1 {
    65     65     file mkdir dir.db
    66     66     set ::log [list]
    67     67     list [catch { sqlite3 dbh dir.db } msg] $msg
    68     68   } {1 {unable to open database file}}
    69     69   
    70         -do_re_test 1.2.2 { lindex $::log 0 } {^os_unix.c: open.*dir.db$}
           70  +do_re_test 1.2.2 { lindex $::log 0 } {^os_unix.c:\d*: \(21\) open\(.*dir.db\) - }
    71     71   
    72     72   # Test a failure in open() due to the path not existing.
    73     73   #
    74     74   do_test 1.3.1 {
    75     75     set ::log [list]
    76     76     list [catch { sqlite3 dbh /x/y/z/test.db } msg] $msg
    77     77   } {1 {unable to open database file}}
    78     78   
    79         -do_re_test 1.3.2 { lindex $::log 0 } {^os_unix.c: open.*test.db$}
           79  +do_re_test 1.3.2 { lindex $::log 0 } {^os_unix.c:\d*: \(2\) open\(.*test.db\) - }
    80     80   
    81     81   # Test a failure in open() due to the path not existing.
    82     82   #
    83     83   do_test 1.4.1 {
    84     84     set ::log [list]
    85     85     list [catch { sqlite3 dbh /root/test.db } msg] $msg
    86     86   } {1 {unable to open database file}}
    87     87   
    88         -do_re_test 1.4.2 { lindex $::log 0 } {^os_unix.c: open.*test.db$}
           88  +do_re_test 1.4.2 { lindex $::log 0 } {^os_unix.c:\d*: \(13\) open\(.*test.db\) - }
    89     89   
    90     90   #--------------------------------------------------------------------------
    91     91   # Tests oserror-1.* test failures in the unlink() system call.
    92     92   #
    93     93   do_test 2.1.1 {
    94     94     set ::log [list]
    95     95     file mkdir test.db-wal
    96     96     forcedelete test.db
    97     97     sqlite3 dbh test.db
    98     98     catchsql { SELECT * FROM sqlite_master } dbh
    99     99   } {1 {disk I/O error}}
   100    100   
   101         -do_re_test 2.1.2 { lindex $::log 0 } {^os_unix.c: unlink.*test.db-wal$}
          101  +do_re_test 2.1.2 { lindex $::log 0 } {^os_unix.c:\d*: \(21\) unlink\(.*test.db-wal\) - }
   102    102   do_test 2.1.3 { 
   103    103     dbh close
   104    104     forcedelete test.db-wal
   105    105   } {}
   106    106     
   107    107   
   108    108   sqlite3_shutdown
   109    109   test_sqlite3_log 
   110    110   sqlite3_initialize
   111    111   finish_test
   112         -