/ Check-in [9109128c]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Use osStat() instead of stat() consistently in os_unix.c
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9109128cb5640d687251dfbefa2fd998063cd9fb
User & Date: drh 2011-07-28 00:14:45
Context
2011-07-28
07:34
Fix conditional for retry logic in winAccess and add missing call to logIoerr. check-in: 8a145863 user: mistachkin tags: trunk
00:14
Use osStat() instead of stat() consistently in os_unix.c check-in: 9109128c user: drh tags: trunk
2011-07-25
23:25
Enable the SQLITE_FCNTL_SIZE_HINT on unix even if SQLITE_FCNTL_CHUNK_SIZE has not been set. check-in: 05c9832e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  4785   4785     ** almost certain that an open() call on the same path will also fail.
  4786   4786     ** For this reason, if an error occurs in the stat() call here, it is
  4787   4787     ** ignored and -1 is returned. The caller will try to open a new file
  4788   4788     ** descriptor on the same path, fail, and return an error to SQLite.
  4789   4789     **
  4790   4790     ** Even if a subsequent open() call does succeed, the consequences of
  4791   4791     ** not searching for a resusable file descriptor are not dire.  */
  4792         -  if( 0==stat(zPath, &sStat) ){
         4792  +  if( 0==osStat(zPath, &sStat) ){
  4793   4793       unixInodeInfo *pInode;
  4794   4794   
  4795   4795       unixEnterMutex();
  4796   4796       pInode = inodeList;
  4797   4797       while( pInode && (pInode->fileId.dev!=sStat.st_dev
  4798   4798                        || pInode->fileId.ino!=sStat.st_ino) ){
  4799   4799          pInode = pInode->pNext;
................................................................................
  4861   4861       */
  4862   4862       nDb = sqlite3Strlen30(zPath) - 1; 
  4863   4863       while( nDb>0 && zPath[nDb]!='-' ) nDb--;
  4864   4864       if( nDb==0 ) return SQLITE_OK;
  4865   4865       memcpy(zDb, zPath, nDb);
  4866   4866       zDb[nDb] = '\0';
  4867   4867   
  4868         -    if( 0==stat(zDb, &sStat) ){
         4868  +    if( 0==osStat(zDb, &sStat) ){
  4869   4869         *pMode = sStat.st_mode & 0777;
  4870   4870       }else{
  4871   4871         rc = SQLITE_IOERR_FSTAT;
  4872   4872       }
  4873   4873     }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
  4874   4874       *pMode = 0600;
  4875   4875     }
................................................................................
  5206   5206   
  5207   5207       default:
  5208   5208         assert(!"Invalid flags argument");
  5209   5209     }
  5210   5210     *pResOut = (osAccess(zPath, amode)==0);
  5211   5211     if( flags==SQLITE_ACCESS_EXISTS && *pResOut ){
  5212   5212       struct stat buf;
  5213         -    if( 0==stat(zPath, &buf) && buf.st_size==0 ){
         5213  +    if( 0==osStat(zPath, &buf) && buf.st_size==0 ){
  5214   5214         *pResOut = 0;
  5215   5215       }
  5216   5216     }
  5217   5217     return SQLITE_OK;
  5218   5218   }
  5219   5219   
  5220   5220