/ Check-in [e7ae120d]
Login

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

Overview
Comment:Fix the openDirectory() routine in the unix VFS so that it works for databases located in the root of the filesystem and for database files that have no pathname at all.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e7ae120d04cffafd9bc2b4ecd68571c17e05ed72
User & Date: drh 2015-12-07 18:18:33
Context
2015-12-07
21:46
Add the ".changes ON|OFF" command to the sqlite3.exe command-line shell, for testing and verifying the sqlite3_changes() and sqlite3_total_changes() interfaces. check-in: 9bbe1afc user: drh tags: trunk
18:18
Fix the openDirectory() routine in the unix VFS so that it works for databases located in the root of the filesystem and for database files that have no pathname at all. check-in: e7ae120d user: drh tags: trunk
16:43
Changes to avoid undefined behavior detected by analysis tools - never observed in the wild. Later: This check-in introduces a bug, fixed at [a304e34675404aee]. check-in: a9e81908 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

3461
3462
3463
3464
3465
3466
3467
3468
3469
3470




3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
*/
static int openDirectory(const char *zFilename, int *pFd){
  int ii;
  int fd = -1;
  char zDirname[MAX_PATHNAME+1];

  sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
  for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--);
  if( ii>1 ){
    zDirname[ii] = '\0';




    fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
    if( fd>=0 ){
      OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
    }
  }
  *pFd = fd;
  if( fd>=0 ) return SQLITE_OK;
  return unixLogError(SQLITE_CANTOPEN_BKPT, "openDirectory", zDirname);
}

/*







|
|

>
>
>
>
|
|
|
<







3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477

3478
3479
3480
3481
3482
3483
3484
*/
static int openDirectory(const char *zFilename, int *pFd){
  int ii;
  int fd = -1;
  char zDirname[MAX_PATHNAME+1];

  sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
  for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--);
  if( ii>0 ){
    zDirname[ii] = '\0';
  }else{
    if( zDirname[0]!='/' ) zDirname[0] = '.';
    zDirname[1] = 0;
  }
  fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
  if( fd>=0 ){
    OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));

  }
  *pFd = fd;
  if( fd>=0 ) return SQLITE_OK;
  return unixLogError(SQLITE_CANTOPEN_BKPT, "openDirectory", zDirname);
}

/*