Classes | Macros | Typedefs | Functions | Variables
tkeyvfs_noroot.cc File Reference
#include <sqlite3.h>
#include "TFile.h"
#include "TKey.h"
#include <cassert>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  unixFile
 
struct  unix_syscall
 
class  RootFileSentry
 

Macros

#define SQLITE_OPEN_WAL   0x00080000 /* VFS only */
 
#define SQLITE_FCNTL_SIZE_HINT   5
 
#define SQLITE_FCNTL_CHUNK_SIZE   6
 
#define SQLITE_FCNTL_SYNC_OMITTED   8
 
#define SQLITE_FCNTL_DB_UNCHANGED   0xca093fa0
 
#define SQLITE_DEFAULT_SECTOR_SIZE   512
 
#define UNUSED_PARAMETER(x)   (void)(x)
 
#define UNUSED_PARAMETER2(x, y)   UNUSED_PARAMETER(x), UNUSED_PARAMETER(y)
 
#define ArraySize(X)   ((int)(sizeof(X) / sizeof(X[0])))
 
#define _LARGE_FILE   1
 
#define _FILE_OFFSET_BITS   64
 
#define _LARGEFILE_SOURCE   1
 
#define TKEYVFS_TRACE   0
 
#define MEMPAGE   2048
 
#define MAX_PATHNAME   512
 
#define SQLITE_TEMP_FILE_PREFIX   "etilqs_"
 
#define O_LARGEFILE   0
 
#define O_NOFOLLOW   0
 
#define O_BINARY   0
 
#define SQLITE_CANTOPEN_BKPT   sqlite3CantopenError(__LINE__)
 
#define osOpen   ((int (*)(const char*, int, ...))aSyscall[0].pCurrent)
 
#define osClose   ((int (*)(int))aSyscall[1].pCurrent)
 
#define osAccess   ((int (*)(const char*, int))aSyscall[2].pCurrent)
 
#define osGetcwd   ((char* (*)(char*, size_t))aSyscall[3].pCurrent)
 
#define osStat   ((int (*)(const char*, struct stat*))aSyscall[4].pCurrent)
 
#define osFstat   ((int (*)(int, struct stat*))aSyscall[5].pCurrent)
 
#define osFtruncate   ((int (*)(int, off_t))aSyscall[6].pCurrent)
 
#define osFcntl   ((int (*)(int, int, ...))aSyscall[7].pCurrent)
 
#define osRead   ((ssize_t(*)(int, void*, size_t))aSyscall[8].pCurrent)
 
#define osPread   ((ssize_t(*)(int, void*, size_t, off_t))aSyscall[9].pCurrent)
 
#define osPread64   ((ssize_t(*)(int, void*, size_t, off_t))aSyscall[10].pCurrent)
 
#define osWrite   ((ssize_t(*)(int, const void*, size_t))aSyscall[11].pCurrent)
 
#define osPwrite   ((ssize_t(*)(int, const void*, size_t, off_t))aSyscall[12].pCurrent)
 
#define osPwrite64   ((ssize_t(*)(int, const void*, size_t, off_t))aSyscall[13].pCurrent)
 
#define osFchmod   ((int (*)(int, mode_t))aSyscall[14].pCurrent)
 
#define osFallocate   ((int (*)(int, off_t, off_t))aSyscall[15].pCurrent)
 
#define unixLogError(a, b, c)   unixLogErrorAtLine(a, b, c, __LINE__)
 
#define UNIXVFS(VFSNAME, FINDER)
 

Typedefs

typedef sqlite_int64 i64
 
typedef struct unixFile unixFile
 
typedef const sqlite3_io_methods *(* finder_type) (const char *, unixFile *)
 

Functions

static int sqlite3CantopenError (int lineno)
 
static int sqlite3Strlen30 (const char *z)
 
static const sqlite3_io_methods * nolockIoFinderImpl (const char *z, unixFile *p)
 
static int unixLogErrorAtLine (int errcode, const char *zFunc, const char *zPath, int iLine)
 
static int robust_open (const char *z, int f, int m)
 
static void robust_close (unixFile *pFile, int h, int lineno)
 
static int unixGetTempname (int nBuf, char *zBuf)
 
static int fcntlSizeHint (unixFile *pFile, i64 nByte)
 
static int seekAndRead (unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt)
 
static int seekAndWrite (unixFile *id, i64 offset, const void *pBuf, int cnt)
 
static int nolockClose (sqlite3_file *id)
 
static int unixRead (sqlite3_file *id, void *pBuf, int amt, sqlite3_int64 offset)
 
static int unixWrite (sqlite3_file *id, const void *pBuf, int amt, sqlite3_int64 offset)
 
static int unixTruncate (sqlite3_file *id, i64 nByte)
 
static int unixSync (sqlite3_file *id, int flags)
 
static int unixFileSize (sqlite3_file *id, i64 *pSize)
 
static int nolockLock (sqlite3_file *NotUsed, int NotUsed2)
 
static int nolockUnlock (sqlite3_file *NotUsed, int NotUsed2)
 
static int nolockCheckReservedLock (sqlite3_file *NotUsed, int *pResOut)
 
static int unixFileControl (sqlite3_file *id, int op, void *pArg)
 
static int unixSectorSize (sqlite3_file *NotUsed)
 
static int unixDeviceCharacteristics (sqlite3_file *NotUsed)
 
static int unixOpen (sqlite3_vfs *pVfs, const char *zPath, sqlite3_file *pFile, int flags, int *pOutFlags)
 
static int unixDelete (sqlite3_vfs *NotUsed, const char *zPath, int dirSync)
 
static int unixAccess (sqlite3_vfs *NotUsed, const char *zPath, int flags, int *pResOut)
 
static int unixFullPathname (sqlite3_vfs *pVfs, const char *zPath, int nOut, char *zOut)
 
static void * unixDlOpen (sqlite3_vfs *NotUsed, const char *zFilename)
 
static void unixDlError (sqlite3_vfs *NotUsed, int nBuf, char *zBufOut)
 
static void unixDlClose (sqlite3_vfs *NotUsed, void *pHandle)
 
static int unixRandomness (sqlite3_vfs *NotUsed, int nBuf, char *zBuf)
 
static int unixSleep (sqlite3_vfs *NotUsed, int microseconds)
 
static int unixCurrentTime (sqlite3_vfs *NotUsed, double *prNow)
 
static int unixGetLastError (sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3)
 
static int unixCurrentTimeInt64 (sqlite3_vfs *NotUsed, sqlite3_int64 *piNow)
 
static int unixSetSystemCall (sqlite3_vfs *pNotUsed, const char *zName, sqlite3_syscall_ptr pNewFunc)
 
static sqlite3_syscall_ptr unixGetSystemCall (sqlite3_vfs *pNotUsed, const char *zName)
 
static const char * unixNextSystemCall (sqlite3_vfs *p, const char *zName)
 
static int closeUnixFile (sqlite3_file *id)
 
int tkeyvfs_init (void)
 
int tkeyvfs_open_v2 (const char *filename, sqlite3 **ppDb, int flags, TFile *rootFile )
 

Variables

static TFile * gRootFile
 
static void(*)(void) unixDlSym (sqlite3_vfs *NotUsed, void *p, const char *zSym)
 
static struct unix_syscall aSyscall []
 
static const sqlite3_io_methods nolockIoMethods
 
static const sqlite3_io_methods *(*const nolockIoFinder )(const char *, unixFile *p)
 

Macro Definition Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 37 of file tkeyvfs_noroot.cc.

#define _LARGE_FILE   1

Definition at line 36 of file tkeyvfs_noroot.cc.

#define _LARGEFILE_SOURCE   1

Definition at line 38 of file tkeyvfs_noroot.cc.

#define ArraySize (   X)    ((int)(sizeof(X) / sizeof(X[0])))

Definition at line 32 of file tkeyvfs_noroot.cc.

#define MAX_PATHNAME   512

Definition at line 87 of file tkeyvfs_noroot.cc.

#define MEMPAGE   2048

Definition at line 82 of file tkeyvfs_noroot.cc.

#define O_BINARY   0

Definition at line 136 of file tkeyvfs_noroot.cc.

#define O_LARGEFILE   0

Definition at line 126 of file tkeyvfs_noroot.cc.

#define O_NOFOLLOW   0

Definition at line 133 of file tkeyvfs_noroot.cc.

#define osAccess   ((int (*)(const char*, int))aSyscall[2].pCurrent)
#define osClose   ((int (*)(int))aSyscall[1].pCurrent)
#define osFallocate   ((int (*)(int, off_t, off_t))aSyscall[15].pCurrent)
#define osFchmod   ((int (*)(int, mode_t))aSyscall[14].pCurrent)
#define osFcntl   ((int (*)(int, int, ...))aSyscall[7].pCurrent)
#define osFstat   ((int (*)(int, struct stat*))aSyscall[5].pCurrent)
#define osFtruncate   ((int (*)(int, off_t))aSyscall[6].pCurrent)
#define osGetcwd   ((char* (*)(char*, size_t))aSyscall[3].pCurrent)
#define osOpen   ((int (*)(const char*, int, ...))aSyscall[0].pCurrent)
#define osPread   ((ssize_t(*)(int, void*, size_t, off_t))aSyscall[9].pCurrent)
#define osPread64   ((ssize_t(*)(int, void*, size_t, off_t))aSyscall[10].pCurrent)
#define osPwrite   ((ssize_t(*)(int, const void*, size_t, off_t))aSyscall[12].pCurrent)
#define osPwrite64   ((ssize_t(*)(int, const void*, size_t, off_t))aSyscall[13].pCurrent)
#define osRead   ((ssize_t(*)(int, void*, size_t))aSyscall[8].pCurrent)
#define osStat   ((int (*)(const char*, struct stat*))aSyscall[4].pCurrent)
#define osWrite   ((ssize_t(*)(int, const void*, size_t))aSyscall[11].pCurrent)
#define SQLITE_CANTOPEN_BKPT   sqlite3CantopenError(__LINE__)

Definition at line 216 of file tkeyvfs_noroot.cc.

#define SQLITE_DEFAULT_SECTOR_SIZE   512

Definition at line 27 of file tkeyvfs_noroot.cc.

#define SQLITE_FCNTL_CHUNK_SIZE   6

Definition at line 23 of file tkeyvfs_noroot.cc.

#define SQLITE_FCNTL_DB_UNCHANGED   0xca093fa0

Definition at line 26 of file tkeyvfs_noroot.cc.

#define SQLITE_FCNTL_SIZE_HINT   5

Definition at line 22 of file tkeyvfs_noroot.cc.

#define SQLITE_FCNTL_SYNC_OMITTED   8

Definition at line 24 of file tkeyvfs_noroot.cc.

#define SQLITE_OPEN_WAL   0x00080000 /* VFS only */

Definition at line 21 of file tkeyvfs_noroot.cc.

#define SQLITE_TEMP_FILE_PREFIX   "etilqs_"

Definition at line 89 of file tkeyvfs_noroot.cc.

#define TKEYVFS_TRACE   0

Definition at line 68 of file tkeyvfs_noroot.cc.

#define unixLogError (   a,
  b,
 
)    unixLogErrorAtLine(a, b, c, __LINE__)

Definition at line 385 of file tkeyvfs_noroot.cc.

#define UNIXVFS (   VFSNAME,
  FINDER 
)
Value:
{ \
1, /* iVersion */ \
sizeof(unixFile), /* szOsFile */ \
MAX_PATHNAME, /* mxPathname */ \
0, /* pNext */ \
VFSNAME, /* zName */ \
(void*)&FINDER, /* pAppData */ \
unixOpen, /* xOpen */ \
unixDelete, /* xDelete */ \
unixAccess, /* xAccess */ \
unixFullPathname, /* xFullPathname */ \
unixDlOpen, /* xDlOpen */ \
unixDlError, /* xDlError */ \
unixDlSym, /* xDlSym */ \
unixDlClose, /* xDlClose */ \
unixRandomness, /* xRandomness */ \
unixSleep, /* xSleep */ \
unixCurrentTime, /* xCurrentTime */ \
unixGetLastError, /* xGetLastError */ \
/* unixCurrentTimeInt64, v2, xCurrentTimeInt64 */ \
/* unixSetSystemCall, v3, xSetSystemCall */ \
/* unixGetSystemCall, v3, xGetSystemCall */ \
/* unixNextSystemCall, v3, xNextSystemCall */ \
}
static void unixDlClose(sqlite3_vfs *NotUsed, void *pHandle)
static int unixDelete(sqlite3_vfs *NotUsed, const char *zPath, int dirSync)
static int unixAccess(sqlite3_vfs *NotUsed, const char *zPath, int flags, int *pResOut)
static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow)
static void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut)
static int unixOpen(sqlite3_vfs *pVfs, const char *zPath, sqlite3_file *pFile, int flags, int *pOutFlags)
static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3)
static void(*)(void) unixDlSym(sqlite3_vfs *NotUsed, void *p, const char *zSym)
static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf)
static int unixFullPathname(sqlite3_vfs *pVfs, const char *zPath, int nOut, char *zOut)
static int unixSleep(sqlite3_vfs *NotUsed, int microseconds)
static void * unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename)
#define UNUSED_PARAMETER (   x)    (void)(x)

Definition at line 29 of file tkeyvfs_noroot.cc.

#define UNUSED_PARAMETER2 (   x,
  y 
)    UNUSED_PARAMETER(x), UNUSED_PARAMETER(y)

Definition at line 30 of file tkeyvfs_noroot.cc.

Typedef Documentation

typedef const sqlite3_io_methods*(* finder_type) (const char *, unixFile *)

Definition at line 367 of file tkeyvfs_noroot.cc.

typedef sqlite_int64 i64

Definition at line 34 of file tkeyvfs_noroot.cc.

typedef struct unixFile unixFile

Definition at line 119 of file tkeyvfs_noroot.cc.

Function Documentation

static int closeUnixFile ( sqlite3_file *  id)
static

Definition at line 472 of file tkeyvfs_noroot.cc.

473 {
474  unixFile* pFile = (unixFile*)id;
475 #if TKEYVFS_TRACE
476  fprintf(stderr, "Begin closeUnixFile ...\n");
477  if (((unixFile*)id)->zPath) {
478  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
479  }
480 #ifndef TKEYVFS_NO_ROOT
481  fprintf(stderr, "saveToRootFile: %d\n", ((unixFile*)id)->saveToRootFile);
482 #endif // TKEYVFS_NO_ROOT
483 #endif /* TKEYVFS_TRACE */
484 #ifndef TKEYVFS_NO_ROOT
485  if (pFile->saveToRootFile) {
486  /**/
487 #if TKEYVFS_TRACE
488  fprintf(
489  stderr, "fileSize: 0x%016lx\n", (unsigned long long)pFile->fileSize);
490 #endif /* TKEYVFS_TRACE */
491  /* Create a tkey which will contain the contents
492  ** of the database in the root file */
493  TKey* k = new TKey(pFile->zPath,
494  "sqlite3 database file",
495  TKey::Class(),
496  pFile->fileSize /*nbytes*/,
497  pFile->rootFile /*dir*/);
498 #if TKEYVFS_TRACE
499  /* Ask the key for the size of the database file it contains. */
500  Int_t objlen = k->GetObjlen();
501  fprintf(stderr, "objlen: %d\n", objlen);
502 #endif /* TKEYVFS_TRACE */
503  /* Add the new key to the root file toplevel directory. */
504  /* Note: The tkey is now owned by the root file. */
505  Int_t cycle = pFile->rootFile->AppendKey(k);
506  /* Get a pointer to the i/o buffer inside the tkey. */
507  char* p = k->GetBuffer();
508  /* Copy the entire in-memory database file into the tkey i/o buffer. */
509  (void*)memcpy((void*)p, (void*)pFile->pBuf, (size_t)pFile->fileSize);
510  /* Write the tkey contents to the root file. */
511  /* Note: This has not yet written the top-level directory entry for the key.
512  */
513  Int_t cnt = k->WriteFile(cycle, 0 /*file*/);
514  if (cnt == -1) {
515  /* bad */
516  fprintf(stderr,
517  "tkeyvfs: failed to write root tkey containing database "
518  "to root file!\n");
519  }
520  /* Force the root file to flush the top-level directory entry for our tkey
521  * to disk. */
522  cnt = pFile->rootFile->Write();
523  if (cnt < 0) {
524  /* bad */
525  fprintf(stderr, "tkeyvfs: failed to write root file to disk!\n");
526  }
527  }
528 #endif // TKEYVFS_NO_ROOT
529  if (pFile->pBuf != nullptr) {
530  free(pFile->pBuf);
531  }
532  if (pFile->zPath != nullptr) {
533  free((void*)pFile->zPath);
534  }
535  memset(pFile, 0, sizeof(unixFile));
536 #if TKEYVFS_TRACE
537  fprintf(stderr, "End closeUnixFile ...\n");
538 #endif /* TKEYVFS_TRACE */
539  return SQLITE_OK;
540 }
TFile * rootFile
Definition: tkeyvfs.cc:99
char * pBuf
Definition: tkeyvfs.cc:102
int saveToRootFile
Definition: tkeyvfs.cc:100
p
Definition: test.py:228
const char * zPath
Definition: tkeyvfs.cc:107
i64 fileSize
Definition: tkeyvfs.cc:104
static int fcntlSizeHint ( unixFile pFile,
i64  nByte 
)
static

Definition at line 589 of file tkeyvfs_noroot.cc.

590 {
591 /**/
592 #if TKEYVFS_TRACE
593  fprintf(stderr, "Begin fcntlSizeHint ...\n");
594 #endif /* TKEYVFS_TRACE */
595  if (pFile->szChunk) {
596  i64 nSize; /* Required file size */
597  i64 nAlloc;
598  nSize = ((nByte + (pFile->szChunk - 1)) / pFile->szChunk) * pFile->szChunk;
599  nAlloc = ((nSize + ((i64)(MEMPAGE - 1))) / ((i64)MEMPAGE)) * ((i64)MEMPAGE);
600  if ((nSize > pFile->fileSize) && (nAlloc > pFile->bufAllocated)) {
601  if (nAlloc > pFile->bufAllocated) {
602  char* pNewBuf = (char*)realloc((void*)pFile->pBuf, (size_t)nAlloc);
603  if (pNewBuf == nullptr) {
604  /**/
605 #if TKEYVFS_TRACE
606  fprintf(stderr, "End fcntlSizeHint ...\n");
607 #endif /* TKEYVFS_TRACE */
608  return SQLITE_IOERR_WRITE;
609  }
610  (void)memset(
611  pNewBuf + pFile->fileSize, 0, (size_t)(nAlloc - pFile->fileSize));
612  pFile->pBuf = pNewBuf;
613  pFile->bufAllocated = nAlloc;
614  } else {
615  (void)memset(
616  pFile->pBuf + pFile->fileSize, 0, (size_t)(nSize - pFile->fileSize));
617  }
618  pFile->fileSize = nSize;
619  }
620  }
621 #if TKEYVFS_TRACE
622  fprintf(stderr, "End fcntlSizeHint ...\n");
623 #endif /* TKEYVFS_TRACE */
624  return SQLITE_OK;
625 }
sqlite_int64 i64
Definition: tkeyvfs.cc:34
char * pBuf
Definition: tkeyvfs.cc:102
#define MEMPAGE
sqlite_int64 i64
i64 bufAllocated
Definition: tkeyvfs.cc:103
int szChunk
Definition: tkeyvfs.cc:108
i64 fileSize
Definition: tkeyvfs.cc:104
static int nolockCheckReservedLock ( sqlite3_file *  NotUsed,
int *  pResOut 
)
static

Definition at line 997 of file tkeyvfs_noroot.cc.

998 {
999 /*UNUSED_PARAMETER(NotUsed);*/
1000 #if TKEYVFS_TRACE
1001  fprintf(stderr, "Begin nolockCheckReservedLock ...\n");
1002  if (((unixFile*)id)->zPath) {
1003  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
1004  }
1005 #endif /* TKEYVFS_TRACE */
1006  *pResOut = 0;
1007 #if TKEYVFS_TRACE
1008  fprintf(stderr, "End nolockCheckReservedLock ...\n");
1009 #endif /* TKEYVFS_TRACE */
1010  return SQLITE_OK;
1011 }
static int nolockClose ( sqlite3_file *  id)
static

Definition at line 717 of file tkeyvfs_noroot.cc.

718 {
719 /**/
720 #if TKEYVFS_TRACE
721  fprintf(stderr, "Begin nolockClose ...\n");
722 #endif /* TKEYVFS_TRACE */
723  int val = closeUnixFile(id);
724 #if TKEYVFS_TRACE
725  fprintf(stderr, "End nolockClose ...\n");
726 #endif /* TKEYVFS_TRACE */
727  return val;
728 }
static int closeUnixFile(sqlite3_file *id)
static const sqlite3_io_methods * nolockIoFinderImpl ( const char *  z,
unixFile p 
)
static

Definition at line 356 of file tkeyvfs_noroot.cc.

357 {
359  UNUSED_PARAMETER(p);
360  return &nolockIoMethods;
361 }
double z
#define UNUSED_PARAMETER(x)
static const sqlite3_io_methods nolockIoMethods
static int nolockLock ( sqlite3_file *  NotUsed,
int  NotUsed2 
)
static

Definition at line 963 of file tkeyvfs_noroot.cc.

964 {
965  /*UNUSED_PARAMETER2(NotUsed, NotUsed2);*/
966  UNUSED_PARAMETER(NotUsed2);
967 #if TKEYVFS_TRACE
968  fprintf(stderr, "Begin nolockLock ...\n");
969  if (((unixFile*)id)->zPath) {
970  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
971  }
972 #endif /* TKEYVFS_TRACE */
973 #if TKEYVFS_TRACE
974  fprintf(stderr, "End nolockLock ...\n");
975 #endif /* TKEYVFS_TRACE */
976  return SQLITE_OK;
977 }
#define UNUSED_PARAMETER(x)
static int nolockUnlock ( sqlite3_file *  NotUsed,
int  NotUsed2 
)
static

Definition at line 980 of file tkeyvfs_noroot.cc.

981 {
982  /*UNUSED_PARAMETER2(NotUsed, NotUsed2);*/
983  UNUSED_PARAMETER(NotUsed2);
984 #if TKEYVFS_TRACE
985  fprintf(stderr, "Begin nolockUnlock ...\n");
986  if (((unixFile*)id)->zPath) {
987  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
988  }
989 #endif /* TKEYVFS_TRACE */
990 #if TKEYVFS_TRACE
991  fprintf(stderr, "End nolockUnlock ...\n");
992 #endif /* TKEYVFS_TRACE */
993  return SQLITE_OK;
994 }
#define UNUSED_PARAMETER(x)
static void robust_close ( unixFile pFile,
int  h,
int  lineno 
)
static

Definition at line 442 of file tkeyvfs_noroot.cc.

443 {
444 /**/
445 #if TKEYVFS_TRACE
446  fprintf(stderr, "Begin robust_close ...\n");
447 #endif /* TKEYVFS_TRACE */
448  if (osClose(h)) {
449  if (pFile) {
450  unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close", pFile->zPath, lineno);
451  } else {
452  unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close", 0, lineno);
453  }
454  }
455 #if TKEYVFS_TRACE
456  fprintf(stderr, "End robust_close ...\n");
457 #endif /* TKEYVFS_TRACE */
458  /**/
459 }
#define osClose
static int unixLogErrorAtLine(int errcode, const char *zFunc, const char *zPath, int iLine)
const char * zPath
Definition: tkeyvfs.cc:107
h
training ###############################
Definition: train_cnn.py:186
static int robust_open ( const char *  z,
int  f,
int  m 
)
static

Definition at line 413 of file tkeyvfs_noroot.cc.

414 {
415  int rc;
416 #if TKEYVFS_TRACE
417  fprintf(stderr, "Begin robust_open ...\n");
418 #endif /* TKEYVFS_TRACE */
419  do {
420  rc = osOpen(z, f, m);
421  } while (rc < 0 && errno == EINTR);
422 #if TKEYVFS_TRACE
423  fprintf(stderr, "End robust_open ...\n");
424 #endif /* TKEYVFS_TRACE */
425  return rc;
426 }
static const double m
Definition: Units.h:79
double z
#define osOpen
static int seekAndRead ( unixFile id,
sqlite3_int64  offset,
void *  pBuf,
int  cnt 
)
static

Definition at line 641 of file tkeyvfs_noroot.cc.

642 {
643 /**/
644 #if TKEYVFS_TRACE
645  fprintf(stderr, "Begin seekAndRead ...\n");
646 #endif /* TKEYVFS_TRACE */
647  if (offset >= id->fileSize) {
648  id->lastErrno = 0;
649 #if TKEYVFS_TRACE
650  fprintf(stderr, "End seekAndRead ...\n");
651 #endif /* TKEYVFS_TRACE */
652  return 0;
653  }
654  if ((offset + cnt) > id->fileSize) {
655  cnt = (offset + cnt) - id->fileSize;
656  }
657  (void*)memcpy(pBuf, (const void*)(id->pBuf + offset), (size_t)cnt);
658 #if TKEYVFS_TRACE
659  fprintf(stderr, "End seekAndRead ...\n");
660 #endif /* TKEYVFS_TRACE */
661  return cnt;
662 }
i64 fileSize
Definition: tkeyvfs.cc:104
static int seekAndWrite ( unixFile id,
i64  offset,
const void *  pBuf,
int  cnt 
)
static

Definition at line 672 of file tkeyvfs_noroot.cc.

673 {
674  unixFile* pFile = (unixFile*)id;
675 #if TKEYVFS_TRACE
676  fprintf(stderr, "Begin seekAndWrite ...\n");
677 #endif /* TKEYVFS_TRACE */
678  if ((offset + (i64)cnt) > id->bufAllocated) {
679  i64 nByte;
680  i64 newBufSize;
681  nByte = offset + ((i64)cnt);
682  if (pFile->szChunk) {
683  nByte =
684  ((nByte + (pFile->szChunk - 1)) / pFile->szChunk) * pFile->szChunk;
685  }
686  newBufSize =
687  ((nByte + (i64)(MEMPAGE - 1)) / ((i64)MEMPAGE)) * ((i64)MEMPAGE);
688  char* pNewBuf = (char*)realloc((void*)id->pBuf, (size_t)(newBufSize));
689  if (pNewBuf == nullptr) {
690  id->lastErrno = errno;
691 #if TKEYVFS_TRACE
692  fprintf(stderr, "End seekAndWrite ...\n");
693 #endif /* TKEYVFS_TRACE */
694  return 0;
695  }
696  if ((offset + (i64)cnt) < newBufSize) {
697  i64 zeroCnt = newBufSize - (offset + (i64)cnt);
698  (void*)memset((void*)(pNewBuf + offset + (i64)cnt), 0, (size_t)zeroCnt);
699  }
700  id->pBuf = pNewBuf;
701  id->bufAllocated = newBufSize;
702  }
703  (void*)memcpy((void*)(id->pBuf + offset), pBuf, (size_t)cnt);
704  if ((offset + (i64)cnt) > id->fileSize) {
705  id->fileSize = offset + (i64)cnt;
706  }
707 #if TKEYVFS_TRACE
708  fprintf(stderr, "End seekAndWrite ...\n");
709 #endif /* TKEYVFS_TRACE */
710  return cnt;
711 }
sqlite_int64 i64
Definition: tkeyvfs.cc:34
#define MEMPAGE
sqlite_int64 i64
i64 bufAllocated
Definition: tkeyvfs.cc:103
int szChunk
Definition: tkeyvfs.cc:108
i64 fileSize
Definition: tkeyvfs.cc:104
static int sqlite3CantopenError ( int  lineno)
static

Definition at line 208 of file tkeyvfs_noroot.cc.

209 {
210  fprintf(stderr,
211  "tkeyvfs.c: cannot open file at line %d of [%.10s]",
212  lineno,
213  20 + sqlite3_sourceid());
214  return SQLITE_CANTOPEN;
215 }
static int sqlite3Strlen30 ( const char *  z)
static

Definition at line 227 of file tkeyvfs_noroot.cc.

228 {
229  const char* z2 = z;
230  if (z == 0) {
231  return 0;
232  }
233  while (*z2) {
234  z2++;
235  }
236  return 0x3fffffff & (int)(z2 - z);
237 }
double z
int tkeyvfs_init ( void  )

Definition at line 1767 of file tkeyvfs_noroot.cc.

1768 {
1769 /*
1770 ** The following macro defines an initializer for an sqlite3_vfs object.
1771 ** The name of the VFS is NAME. The pAppData is a pointer to a pointer
1772 ** to the "finder" function. (pAppData is a pointer to a pointer because
1773 ** silly C90 rules prohibit a void* from being cast to a function pointer
1774 ** and so we have to go through the intermediate pointer to avoid problems
1775 ** when compiling with -pedantic-errors on GCC.)
1776 **
1777 ** The FINDER parameter to this macro is the name of the pointer to the
1778 ** finder-function. The finder-function returns a pointer to the
1779 ** sqlite_io_methods object that implements the desired locking
1780 ** behaviors. See the division above that contains the IOMETHODS
1781 ** macro for addition information on finder-functions.
1782 **
1783 ** Most finders simply return a pointer to a fixed sqlite3_io_methods
1784 ** object. But the "autolockIoFinder" available on MacOSX does a little
1785 ** more than that; it looks at the filesystem type that hosts the
1786 ** database file and tries to choose an locking method appropriate for
1787 ** that filesystem time.
1788 */
1789 #define UNIXVFS(VFSNAME, FINDER) \
1790  { \
1791  1, /* iVersion */ \
1792  sizeof(unixFile), /* szOsFile */ \
1793  MAX_PATHNAME, /* mxPathname */ \
1794  0, /* pNext */ \
1795  VFSNAME, /* zName */ \
1796  (void*)&FINDER, /* pAppData */ \
1797  unixOpen, /* xOpen */ \
1798  unixDelete, /* xDelete */ \
1799  unixAccess, /* xAccess */ \
1800  unixFullPathname, /* xFullPathname */ \
1801  unixDlOpen, /* xDlOpen */ \
1802  unixDlError, /* xDlError */ \
1803  unixDlSym, /* xDlSym */ \
1804  unixDlClose, /* xDlClose */ \
1805  unixRandomness, /* xRandomness */ \
1806  unixSleep, /* xSleep */ \
1807  unixCurrentTime, /* xCurrentTime */ \
1808  unixGetLastError, /* xGetLastError */ \
1809  /* unixCurrentTimeInt64, v2, xCurrentTimeInt64 */ \
1810  /* unixSetSystemCall, v3, xSetSystemCall */ \
1811  /* unixGetSystemCall, v3, xGetSystemCall */ \
1812  /* unixNextSystemCall, v3, xNextSystemCall */ \
1813  }
1814  /*
1815  ** All default VFSes for unix are contained in the following array.
1816  **
1817  ** Note that the sqlite3_vfs.pNext field of the VFS object is modified
1818  ** by the SQLite core when the VFS is registered. So the following
1819  ** array cannot be const.
1820  */
1821  static sqlite3_vfs aVfs[] = {
1822  UNIXVFS("tkeyvfs", nolockIoFinder),
1823  };
1824  unsigned int i; /* Loop counter */
1825  /* Double-check that the aSyscall[] array has been constructed
1826  ** correctly. See ticket [bb3a86e890c8e96ab] */
1827  assert(ArraySize(aSyscall) == 16);
1828  /* Register all VFSes defined in the aVfs[] array */
1829  for (i = 0; i < (sizeof(aVfs) / sizeof(sqlite3_vfs)); i++) {
1830  sqlite3_vfs_register(&aVfs[i], 0);
1831  }
1832  return SQLITE_OK;
1833 }
#define ArraySize(X)
static const sqlite3_io_methods *(*const nolockIoFinder)(const char *, unixFile *p)
static struct unix_syscall aSyscall[]
#define UNIXVFS(VFSNAME, FINDER)
int tkeyvfs_open_v2 ( const char *  filename,
sqlite3 **  ppDb,
int  flags,
TFile *  rootFile 
)

Definition at line 1836 of file tkeyvfs_noroot.cc.

1844 {
1845 #ifndef TKEYVFS_NO_ROOT
1846  RootFileSentry rfs(rootFile);
1847  // Note that the sentry *is* the correct thing to do, here:
1848  // gRootFile is required in unixOpen(), which is called as part of
1849  // the chain of functions of which sqlite3_open_v2() is the first
1850  // call. By the time we return from sqlite3_open_v2() then, we no
1851  // longer require gRootFile and the sentry can do the job of
1852  // cleaning up when it goes out of scope.
1853 #endif // TKEYVFS_NO_ROOT
1854  return sqlite3_open_v2(filename,
1855  ppDb,
1856  flags,
1857 #ifdef TKEYVFS_NO_ROOT
1858  nullptr
1859 #else
1860  "tkeyvfs"
1861 #endif
1862  );
1863 }
static int unixAccess ( sqlite3_vfs *  NotUsed,
const char *  zPath,
int  flags,
int *  pResOut 
)
static

Definition at line 1329 of file tkeyvfs_noroot.cc.

1334 {
1335  int amode = 0;
1336  UNUSED_PARAMETER(NotUsed);
1337 #if TKEYVFS_TRACE
1338  fprintf(stderr, "Begin unixAccess ...\n");
1339  if (zPath != nullptr) {
1340  fprintf(stderr, "filename: %s\n", zPath);
1341  }
1342 #endif /* TKEYVFS_TRACE */
1343  switch (flags) {
1344  case SQLITE_ACCESS_EXISTS:
1345  /**/
1346 #if TKEYVFS_TRACE
1347  fprintf(stderr, "op: SQLITE_ACCESS_EXISTS\n");
1348 #endif /* TKEYVFS_TRACE */
1349  amode = F_OK;
1350  break;
1351  case SQLITE_ACCESS_READWRITE:
1352  /**/
1353 #if TKEYVFS_TRACE
1354  fprintf(stderr, "op: SQLITE_ACCESS_READWRITE\n");
1355 #endif /* TKEYVFS_TRACE */
1356  amode = W_OK | R_OK;
1357  break;
1358  case SQLITE_ACCESS_READ:
1359  /**/
1360 #if TKEYVFS_TRACE
1361  fprintf(stderr, "op: SQLITE_ACCESS_READ\n");
1362 #endif /* TKEYVFS_TRACE */
1363  amode = R_OK;
1364  break;
1365  default:
1366  assert(!"Invalid flags argument");
1367  }
1368  *pResOut = 0;
1369 #if TKEYVFS_TRACE
1370  fprintf(stderr, "End unixAccess ...\n");
1371 #endif /* TKEYVFS_TRACE */
1372  return SQLITE_OK;
1373 }
#define UNUSED_PARAMETER(x)
static int unixCurrentTime ( sqlite3_vfs *  NotUsed,
double *  prNow 
)
static

Definition at line 1569 of file tkeyvfs_noroot.cc.

1570 {
1571  sqlite3_int64 i;
1572  UNUSED_PARAMETER(NotUsed);
1573 #if TKEYVFS_TRACE
1574  fprintf(stderr, "Begin unixCurrentTime ...\n");
1575 #endif /* TKEYVFS_TRACE */
1576  unixCurrentTimeInt64(0, &i);
1577  *prNow = i / 86400000.0;
1578 #if TKEYVFS_TRACE
1579  fprintf(stderr, "End unixCurrentTime ...\n");
1580 #endif /* TKEYVFS_TRACE */
1581  return 0;
1582 }
static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow)
#define UNUSED_PARAMETER(x)
static int unixCurrentTimeInt64 ( sqlite3_vfs *  NotUsed,
sqlite3_int64 *  piNow 
)
static

Definition at line 1614 of file tkeyvfs_noroot.cc.

1615 {
1616  static const sqlite3_int64 unixEpoch = 24405875 * (sqlite3_int64)8640000;
1617  struct timeval sNow;
1618 #if TKEYVFS_TRACE
1619  fprintf(stderr, "Begin unixCurrentTimeInt64 ...\n");
1620 #endif /* TKEYVFS_TRACE */
1621  gettimeofday(&sNow, 0);
1622  *piNow = unixEpoch + 1000 * (sqlite3_int64)sNow.tv_sec + sNow.tv_usec / 1000;
1623  UNUSED_PARAMETER(NotUsed);
1624 #if TKEYVFS_TRACE
1625  fprintf(stderr, "End unixCurrentTimeInt64 ...\n");
1626 #endif /* TKEYVFS_TRACE */
1627  return 0;
1628 }
#define UNUSED_PARAMETER(x)
static int unixDelete ( sqlite3_vfs *  NotUsed,
const char *  zPath,
int  dirSync 
)
static

Definition at line 1299 of file tkeyvfs_noroot.cc.

1303 {
1304  int rc = SQLITE_OK;
1305  UNUSED_PARAMETER(NotUsed);
1306 #if TKEYVFS_TRACE
1307  fprintf(stderr, "Begin unixDelete ...\n");
1308  if (zPath != nullptr) {
1309  fprintf(stderr, "filename: %s\n", zPath);
1310  }
1311 #endif /* TKEYVFS_TRACE */
1312 #if TKEYVFS_TRACE
1313  fprintf(stderr, "End unixDelete ...\n");
1314 #endif /* TKEYVFS_TRACE */
1315  return rc;
1316 }
#define UNUSED_PARAMETER(x)
static int unixDeviceCharacteristics ( sqlite3_file *  NotUsed)
static

Definition at line 1132 of file tkeyvfs_noroot.cc.

1133 {
1134  UNUSED_PARAMETER(NotUsed);
1135 #if TKEYVFS_TRACE
1136  fprintf(stderr, "Begin unixDeviceCharacteristics ...\n");
1137 #endif /* TKEYVFS_TRACE */
1138 #if TKEYVFS_TRACE
1139  fprintf(stderr, "End unixDeviceCharacteristics ...\n");
1140 #endif /* TKEYVFS_TRACE */
1141  return 0;
1142 }
#define UNUSED_PARAMETER(x)
static void unixDlClose ( sqlite3_vfs *  NotUsed,
void *  pHandle 
)
static

Definition at line 1480 of file tkeyvfs_noroot.cc.

1481 {
1482  UNUSED_PARAMETER(NotUsed);
1483 #if TKEYVFS_TRACE
1484  fprintf(stderr, "Begin unixDlClose ...\n");
1485 #endif /* TKEYVFS_TRACE */
1486  dlclose(pHandle);
1487 #if TKEYVFS_TRACE
1488  fprintf(stderr, "End unixDlClose ...\n");
1489 #endif /* TKEYVFS_TRACE */
1490  /**/
1491 }
#define UNUSED_PARAMETER(x)
static void unixDlError ( sqlite3_vfs *  NotUsed,
int  nBuf,
char *  zBufOut 
)
static

Definition at line 1434 of file tkeyvfs_noroot.cc.

1435 {
1436  const char* zErr;
1437  UNUSED_PARAMETER(NotUsed);
1438 #if TKEYVFS_TRACE
1439  fprintf(stderr, "Begin unixDlError ...\n");
1440 #endif /* TKEYVFS_TRACE */
1441  zErr = dlerror();
1442  if (zErr) {
1443  sqlite3_snprintf(nBuf, zBufOut, "%s", zErr);
1444  }
1445 #if TKEYVFS_TRACE
1446  fprintf(stderr, "End unixDlError ...\n");
1447 #endif /* TKEYVFS_TRACE */
1448  /**/
1449 }
#define UNUSED_PARAMETER(x)
static void * unixDlOpen ( sqlite3_vfs *  NotUsed,
const char *  zFilename 
)
static

Definition at line 1413 of file tkeyvfs_noroot.cc.

1414 {
1415  UNUSED_PARAMETER(NotUsed);
1416 #if TKEYVFS_TRACE
1417  fprintf(stderr, "Begin unixFullPathName ...\n");
1418 #endif /* TKEYVFS_TRACE */
1419  void* p = dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL);
1420 #if TKEYVFS_TRACE
1421  fprintf(stderr, "End unixFullPathName ...\n");
1422 #endif /* TKEYVFS_TRACE */
1423  return p;
1424 }
#define UNUSED_PARAMETER(x)
p
Definition: test.py:228
static int unixFileControl ( sqlite3_file *  id,
int  op,
void *  pArg 
)
static

Definition at line 1017 of file tkeyvfs_noroot.cc.

1018 {
1019 /**/
1020 #if TKEYVFS_TRACE
1021  fprintf(stderr, "Begin unixFileControl ...\n");
1022  if (((unixFile*)id)->zPath) {
1023  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
1024  }
1025 #endif /* TKEYVFS_TRACE */
1026  switch (op) {
1027  case SQLITE_FCNTL_LOCKSTATE: {
1028  /**/
1029 #if TKEYVFS_TRACE
1030  fprintf(stderr, "op: LOCKSTATE\n");
1031 #endif /* TKEYVFS_TRACE */
1032  *(int*)pArg = ((unixFile*)id)->eFileLock;
1033  /*SQLITE_LOCK_NONE*/
1034 #if TKEYVFS_TRACE
1035  fprintf(stderr, "End unixFileControl ...\n");
1036 #endif /* TKEYVFS_TRACE */
1037  return SQLITE_OK;
1038  }
1039  case SQLITE_LAST_ERRNO: {
1040  /**/
1041 #if TKEYVFS_TRACE
1042  fprintf(stderr, "op: LAST_ERRNO\n");
1043 #endif /* TKEYVFS_TRACE */
1044  *(int*)pArg = ((unixFile*)id)->lastErrno;
1045 #if TKEYVFS_TRACE
1046  fprintf(stderr, "End unixFileControl ...\n");
1047 #endif /* TKEYVFS_TRACE */
1048  return SQLITE_OK;
1049  }
1050  case SQLITE_FCNTL_CHUNK_SIZE: {
1051  /**/
1052 #if TKEYVFS_TRACE
1053  fprintf(stderr, "op: CHUNK_SIZE\n");
1054  fprintf(stderr, "szChunk: %d\n", *(int*)pArg);
1055 #endif /* TKEYVFS_TRACE */
1056  ((unixFile*)id)->szChunk = *(int*)pArg;
1057 #if TKEYVFS_TRACE
1058  fprintf(stderr, "End unixFileControl ...\n");
1059 #endif /* TKEYVFS_TRACE */
1060  return SQLITE_OK;
1061  }
1062  case SQLITE_FCNTL_SIZE_HINT: {
1063  /**/
1064 #if TKEYVFS_TRACE
1065  fprintf(stderr, "op: SIZE_HINT\n");
1066  fprintf(stderr, "hint: 0x%016lx\n", *(i64*)pArg);
1067 #endif /* TKEYVFS_TRACE */
1068  int val = fcntlSizeHint((unixFile*)id, *(i64*)pArg);
1069 #if TKEYVFS_TRACE
1070  fprintf(stderr, "End unixFileControl ...\n");
1071 #endif /* TKEYVFS_TRACE */
1072  return val;
1073  }
1074  /* The pager calls this method to signal that it has done
1075  ** a rollback and that the database is therefore unchanged and
1076  ** it hence it is OK for the transaction change counter to be
1077  ** unchanged.
1078  */
1080  /**/
1081 #if TKEYVFS_TRACE
1082  fprintf(stderr, "op: DB_UNCHANGED\n");
1083 #endif /* TKEYVFS_TRACE */
1084  ((unixFile*)id)->dbUpdate = 0;
1085 #if TKEYVFS_TRACE
1086  fprintf(stderr, "End unixFileControl ...\n");
1087 #endif /* TKEYVFS_TRACE */
1088  return SQLITE_OK;
1089  }
1091  /**/
1092 #if TKEYVFS_TRACE
1093  fprintf(stderr, "op: SYNC_OMITTED\n");
1094  fprintf(stderr, "End unixFileControl ...\n");
1095 #endif /* TKEYVFS_TRACE */
1096  return SQLITE_OK; /* A no-op */
1097  }
1098  }
1099 #if TKEYVFS_TRACE
1100  fprintf(stderr, "End unixFileControl ...\n");
1101 #endif /* TKEYVFS_TRACE */
1102  return SQLITE_NOTFOUND;
1103 }
sqlite_int64 i64
Definition: tkeyvfs.cc:34
#define SQLITE_FCNTL_SYNC_OMITTED
#define SQLITE_FCNTL_DB_UNCHANGED
#define SQLITE_FCNTL_SIZE_HINT
static int fcntlSizeHint(unixFile *pFile, i64 nByte)
#define SQLITE_FCNTL_CHUNK_SIZE
static int unixFileSize ( sqlite3_file *  id,
i64 pSize 
)
static

Definition at line 937 of file tkeyvfs_noroot.cc.

938 {
939  unixFile* p = (unixFile*)id;
940 #if TKEYVFS_TRACE
941  fprintf(stderr, "Begin unixFileSize ...\n");
942  if (((unixFile*)id)->zPath) {
943  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
944  }
945 #endif /* TKEYVFS_TRACE */
946  *pSize = p->fileSize;
947  /* When opening a zero-size database, the findInodeInfo() procedure
948  ** writes a single byte into that file in order to work around a bug
949  ** in the OS-X msdos filesystem. In order to avoid problems with upper
950  ** layers, we need to report this file size as zero even though it is
951  ** really 1. Ticket #3260.
952  */
953  if (*pSize == 1) {
954  *pSize = 0;
955  }
956 #if TKEYVFS_TRACE
957  fprintf(stderr, "End unixFileSize ...\n");
958 #endif /* TKEYVFS_TRACE */
959  return SQLITE_OK;
960 }
p
Definition: test.py:228
i64 fileSize
Definition: tkeyvfs.cc:104
static int unixFullPathname ( sqlite3_vfs *  pVfs,
const char *  zPath,
int  nOut,
char *  zOut 
)
static

Definition at line 1385 of file tkeyvfs_noroot.cc.

1390 {
1391 /**/
1392 #if TKEYVFS_TRACE
1393  fprintf(stderr, "Begin unixFullPathName ...\n");
1394  if (zPath != nullptr) {
1395  fprintf(stderr, "filename: %s\n", zPath);
1396  }
1397 #endif /* TKEYVFS_TRACE */
1398  assert(pVfs->mxPathname == MAX_PATHNAME);
1399  UNUSED_PARAMETER(pVfs);
1400  zOut[nOut - 1] = '\0';
1401  sqlite3_snprintf(nOut, zOut, "%s", zPath);
1402 #if TKEYVFS_TRACE
1403  fprintf(stderr, "End unixFullPathName ...\n");
1404 #endif /* TKEYVFS_TRACE */
1405  return SQLITE_OK;
1406 }
#define UNUSED_PARAMETER(x)
#define MAX_PATHNAME
static int unixGetLastError ( sqlite3_vfs *  NotUsed,
int  NotUsed2,
char *  NotUsed3 
)
static

Definition at line 1592 of file tkeyvfs_noroot.cc.

1593 {
1594  UNUSED_PARAMETER(NotUsed);
1595  UNUSED_PARAMETER(NotUsed2);
1596  UNUSED_PARAMETER(NotUsed3);
1597 #if TKEYVFS_TRACE
1598  fprintf(stderr, "Begin unixGetLastError ...\n");
1599  fprintf(stderr, "End unixGetLastError ...\n");
1600 #endif /* TKEYVFS_TRACE */
1601  return 0;
1602 }
#define UNUSED_PARAMETER(x)
static sqlite3_syscall_ptr unixGetSystemCall ( sqlite3_vfs *  pNotUsed,
const char *  zName 
)
static

Definition at line 1689 of file tkeyvfs_noroot.cc.

1690 {
1691  unsigned int i;
1692  UNUSED_PARAMETER(pNotUsed);
1693 #if TKEYVFS_TRACE
1694  fprintf(stderr, "Begin unixGetSystemCall ...\n");
1695 #endif /* TKEYVFS_TRACE */
1696  for (i = 0; i < sizeof(aSyscall) / sizeof(aSyscall[0]); i++) {
1697  if (strcmp(zName, aSyscall[i].zName) == 0) {
1698  /**/
1699 #if TKEYVFS_TRACE
1700  fprintf(stderr, "End unixGetSystemCall ...\n");
1701 #endif /* TKEYVFS_TRACE */
1702  return aSyscall[i].pCurrent;
1703  }
1704  }
1705 #if TKEYVFS_TRACE
1706  fprintf(stderr, "End unixGetSystemCall ...\n");
1707 #endif /* TKEYVFS_TRACE */
1708  return 0;
1709 }
sqlite3_syscall_ptr pCurrent
Definition: tkeyvfs.cc:248
static struct unix_syscall aSyscall[]
#define UNUSED_PARAMETER(x)
static int unixGetTempname ( int  nBuf,
char *  zBuf 
)
static

Definition at line 548 of file tkeyvfs_noroot.cc.

549 {
550  static const unsigned char zChars[] = "abcdefghijklmnopqrstuvwxyz"
551  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
552  "0123456789";
553  unsigned int i, j;
554 #if TKEYVFS_TRACE
555  fprintf(stderr, "Begin unixGetTempname ...\n");
556 #endif /* TKEYVFS_TRACE */
557  /* Check that the output buffer is large enough for the temporary file
558  ** name. If it is not, return SQLITE_ERROR.
559  */
560  if ((strlen(SQLITE_TEMP_FILE_PREFIX) + 17) >= (size_t)nBuf) {
561  /**/
562 #if TKEYVFS_TRACE
563  fprintf(stderr, "End unixGetTempname ...\n");
564 #endif /* TKEYVFS_TRACE */
565  return SQLITE_ERROR;
566  }
567  sqlite3_snprintf(nBuf - 17, zBuf, SQLITE_TEMP_FILE_PREFIX);
568  j = (int)strlen(zBuf);
569  sqlite3_randomness(15, &zBuf[j]);
570  for (i = 0; i < 15; i++, j++) {
571  zBuf[j] = (char)zChars[((unsigned char)zBuf[j]) % (sizeof(zChars) - 1)];
572  }
573  zBuf[j] = 0;
574 #if TKEYVFS_TRACE
575  fprintf(stderr, "End unixGetTempname ...\n");
576 #endif /* TKEYVFS_TRACE */
577  return SQLITE_OK;
578 }
#define SQLITE_TEMP_FILE_PREFIX
static int unixLogErrorAtLine ( int  errcode,
const char *  zFunc,
const char *  zPath,
int  iLine 
)
static

Definition at line 387 of file tkeyvfs_noroot.cc.

392 {
393  char* zErr; /* Message from strerror() or equivalent */
394  int iErrno = errno; /* Saved syscall error number */
395  zErr = strerror(iErrno);
396  if (zPath == 0) {
397  zPath = "";
398  }
399  fprintf(stderr,
400  "tkeyvfs.c:%d: (%d) %s(%s) - %s",
401  iLine,
402  iErrno,
403  zFunc,
404  zPath,
405  zErr);
406  return errcode;
407 }
static const char * unixNextSystemCall ( sqlite3_vfs *  p,
const char *  zName 
)
static

Definition at line 1718 of file tkeyvfs_noroot.cc.

1719 {
1720  int i = -1;
1722 #if TKEYVFS_TRACE
1723  fprintf(stderr, "Begin unixNextSystemCall ...\n");
1724 #endif /* TKEYVFS_TRACE */
1725  if (zName) {
1726  for (i = 0; i < ArraySize(aSyscall) - 1; i++) {
1727  if (strcmp(zName, aSyscall[i].zName) == 0) {
1728  break;
1729  }
1730  }
1731  }
1732  for (i++; i < ArraySize(aSyscall); i++) {
1733  if (aSyscall[i].pCurrent != 0) {
1734  /**/
1735 #if TKEYVFS_TRACE
1736  fprintf(stderr, "End unixNextSystemCall ...\n");
1737 #endif /* TKEYVFS_TRACE */
1738  return aSyscall[i].zName;
1739  }
1740  }
1741 #if TKEYVFS_TRACE
1742  fprintf(stderr, "End unixNextSystemCall ...\n");
1743 #endif /* TKEYVFS_TRACE */
1744  return nullptr;
1745 }
#define ArraySize(X)
const char * zName
Definition: tkeyvfs.cc:247
static struct unix_syscall aSyscall[]
#define UNUSED_PARAMETER(x)
p
Definition: test.py:228
static int unixOpen ( sqlite3_vfs *  pVfs,
const char *  zPath,
sqlite3_file *  pFile,
int  flags,
int *  pOutFlags 
)
static

Definition at line 1170 of file tkeyvfs_noroot.cc.

1176 {
1177  unixFile* p = (unixFile*)pFile;
1178  int eType = flags & 0xFFFFFF00; /* Type of file to open */
1179  int rc = SQLITE_OK;
1180  // int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); // Not used.
1181  int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE);
1182  int isCreate = (flags & SQLITE_OPEN_CREATE);
1183  int isReadonly = (flags & SQLITE_OPEN_READONLY);
1184  int isReadWrite = (flags & SQLITE_OPEN_READWRITE);
1185  char zTmpname[MAX_PATHNAME + 1];
1186  const char* zName = zPath;
1187 #if TKEYVFS_TRACE
1188  fprintf(stderr, "Begin unixOpen ...\n");
1189  if (zPath != nullptr) {
1190  fprintf(stderr, "filename: %s\n", zPath);
1191  }
1192 #endif /* TKEYVFS_TRACE */
1193  memset(p, 0, sizeof(unixFile));
1194  if (pOutFlags) {
1195  *pOutFlags = flags;
1196  }
1197  if (!zName) {
1198  rc = unixGetTempname(MAX_PATHNAME + 1, zTmpname);
1199  if (rc != SQLITE_OK) {
1200  return rc;
1201  }
1202  zName = zTmpname;
1203  }
1204  if (zName != nullptr) {
1205  p->zPath = (char*)malloc(strlen(zName) + 1);
1206  if (p->zPath != nullptr) {
1207  (void*)strcpy((char*)p->zPath, zName);
1208  }
1209  }
1210  p->lastErrno = 0;
1211  p->pMethod = &nolockIoMethods;
1212 #ifndef TKEYVFS_NO_ROOT
1213  p->rootFile = nullptr;
1214  if (eType & SQLITE_OPEN_MAIN_DB) {
1215  p->rootFile = gRootFile;
1216  }
1217  p->saveToRootFile =
1218  (p->rootFile && p->rootFile->IsWritable() &&
1219  (eType & SQLITE_OPEN_MAIN_DB) && (isCreate || isReadWrite) && !isDelete);
1220 #endif // TKEYVFS_NO_ROOT
1221  if ((eType & SQLITE_OPEN_MAIN_DB) && !isCreate) {
1222  /**/
1223  i64 nBytes = 0;
1224  i64 nAlloc = 0;
1225 #ifndef TKEYVFS_NO_ROOT
1226  Bool_t status = kFALSE;
1227  TKey* k = 0;
1228  char* pKeyBuf = 0;
1229  /* Read the highest numbered cycle of the tkey which contains
1230  ** the database from the root file. */
1231  k = p->rootFile->GetKey(p->zPath, 9999 /*cycle*/);
1232  /* Force the tkey to allocate an i/o buffer for its contents. */
1233  k->SetBuffer();
1234  /* Read the contents of the tkey from the root file. */
1235  status = k->ReadFile();
1236  if (!status) {
1237  /**/
1238 #if TKEYVFS_TRACE
1239  fprintf(stderr, "End unixOpen ...\n");
1240 #endif /* TKEYVFS_TRACE */
1241  rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
1242  return rc;
1243  }
1244  /* Get a pointer to the tkey i/o buffer. */
1245  pKeyBuf = k->GetBuffer();
1246  /* Get the size of the contained database file from the tkey. */
1247  nBytes = k->GetObjlen();
1248  /* Allocate enough memory pages to contain the database file. */
1249  nAlloc =
1250  ((nBytes + ((i64)(MEMPAGE - 1))) / ((i64)MEMPAGE)) * ((i64)MEMPAGE);
1251  p->pBuf = (char*)malloc((size_t)nAlloc);
1252 #else // TKEYVFS_NO_ROOT
1253  /* If not using root, a database file read is a noop. */
1254  nBytes = 0;
1255  nAlloc = MEMPAGE;
1256  p->pBuf = (char*)calloc(1, MEMPAGE);
1257 #endif // TKEYVFS_NO_ROOT
1258  if (p->pBuf == nullptr) {
1259  /**/
1260 #if TKEYVFS_TRACE
1261  fprintf(stderr, "End unixOpen ...\n");
1262 #endif /* TKEYVFS_TRACE */
1263  rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
1264  return rc;
1265  }
1266 #ifndef TKEYVFS_NO_ROOT
1267  /* Copy the entire database file from the tkey i/o buffer
1268  ** into our in-memory database. */
1269  (void*)memcpy(p->pBuf, pKeyBuf, (size_t)nBytes);
1270 #endif // TKEYVFS_NO_ROOT
1271  p->bufAllocated = nAlloc;
1272  p->fileSize = nBytes;
1273  /**/
1274  } else {
1275  p->pBuf = (char*)calloc(1, MEMPAGE);
1276  if (p->pBuf == nullptr) {
1277  /**/
1278 #if TKEYVFS_TRACE
1279  fprintf(stderr, "End unixOpen ...\n");
1280 #endif /* TKEYVFS_TRACE */
1281  rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
1282  return rc;
1283  }
1284  p->bufAllocated = MEMPAGE;
1285  p->fileSize = 0;
1286  }
1287  rc = SQLITE_OK;
1288 #if TKEYVFS_TRACE
1289  fprintf(stderr, "End unixOpen ...\n");
1290 #endif /* TKEYVFS_TRACE */
1291  return rc;
1292 }
#define unixLogError(a, b, c)
sqlite_int64 i64
Definition: tkeyvfs.cc:34
TFile * rootFile
Definition: tkeyvfs.cc:99
char * pBuf
Definition: tkeyvfs.cc:102
static TFile * gRootFile
#define MEMPAGE
static int unixGetTempname(int nBuf, char *zBuf)
sqlite_int64 i64
sqlite3_io_methods const * pMethod
Definition: tkeyvfs.cc:97
int saveToRootFile
Definition: tkeyvfs.cc:100
p
Definition: test.py:228
#define MAX_PATHNAME
i64 bufAllocated
Definition: tkeyvfs.cc:103
int lastErrno
Definition: tkeyvfs.cc:106
static const sqlite3_io_methods nolockIoMethods
#define SQLITE_CANTOPEN_BKPT
const char * zPath
Definition: tkeyvfs.cc:107
i64 fileSize
Definition: tkeyvfs.cc:104
static int unixRandomness ( sqlite3_vfs *  NotUsed,
int  nBuf,
char *  zBuf 
)
static

Definition at line 1497 of file tkeyvfs_noroot.cc.

1498 {
1499  UNUSED_PARAMETER(NotUsed);
1500  assert((size_t)nBuf >= (sizeof(time_t) + sizeof(int)));
1501 #if TKEYVFS_TRACE
1502  fprintf(stderr, "Begin unixRandomness ...\n");
1503 #endif /* TKEYVFS_TRACE */
1504  /* We have to initialize zBuf to prevent valgrind from reporting
1505  ** errors. The reports issued by valgrind are incorrect - we would
1506  ** prefer that the randomness be increased by making use of the
1507  ** uninitialized space in zBuf - but valgrind errors tend to worry
1508  ** some users. Rather than argue, it seems easier just to initialize
1509  ** the whole array and silence valgrind, even if that means less randomness
1510  ** in the random seed.
1511  **
1512  ** When testing, initializing zBuf[] to zero is all we do. That means
1513  ** that we always use the same random number sequence. This makes the
1514  ** tests repeatable.
1515  */
1516  memset(zBuf, 0, nBuf);
1517  {
1518  int pid, fd;
1519  fd = robust_open("/dev/urandom", O_RDONLY, 0);
1520  if (fd < 0) {
1521  time_t t;
1522  time(&t);
1523  memcpy(zBuf, &t, sizeof(t));
1524  pid = getpid();
1525  memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
1526  assert(sizeof(t) + sizeof(pid) <= (size_t)nBuf);
1527  nBuf = sizeof(t) + sizeof(pid);
1528  } else {
1529  do {
1530  nBuf = osRead(fd, zBuf, nBuf);
1531  } while (nBuf < 0 && errno == EINTR);
1532  robust_close(0, fd, __LINE__);
1533  }
1534  }
1535 #if TKEYVFS_TRACE
1536  fprintf(stderr, "End unixRandomness ...\n");
1537 #endif /* TKEYVFS_TRACE */
1538  return nBuf;
1539 }
#define osRead
static int robust_open(const char *z, int f, int m)
static void robust_close(unixFile *pFile, int h, int lineno)
#define UNUSED_PARAMETER(x)
static int unixRead ( sqlite3_file *  id,
void *  pBuf,
int  amt,
sqlite3_int64  offset 
)
static

Definition at line 736 of file tkeyvfs_noroot.cc.

737 {
738  unixFile* pFile = (unixFile*)id;
739  int got;
740 #if TKEYVFS_TRACE
741  fprintf(stderr, "Begin unixRead ...\n");
742  if (((unixFile*)id)->zPath) {
743  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
744  }
745  fprintf(
746  stderr, "offset: 0x%016lx amt: 0x%08x\n", (unsigned long long)offset, amt);
747 #endif /* TKEYVFS_TRACE */
748  got = seekAndRead(pFile, offset, pBuf, amt);
749  if (got == amt) {
750  /**/
751 #if TKEYVFS_TRACE
752  fprintf(stderr, "End unixRead ...\n");
753 #endif /* TKEYVFS_TRACE */
754  return SQLITE_OK;
755  } else if (got < 0) {
756  /* lastErrno set by seekAndRead */
757 #if TKEYVFS_TRACE
758  fprintf(stderr, "End unixRead ...\n");
759 #endif /* TKEYVFS_TRACE */
760  return SQLITE_IOERR_READ;
761  } else {
762  pFile->lastErrno = 0; /* not a system error */
763  /* Unread parts of the buffer must be zero-filled */
764  memset(&((char*)pBuf)[got], 0, amt - got);
765 #if TKEYVFS_TRACE
766  fprintf(stderr, "End unixRead ...\n");
767 #endif /* TKEYVFS_TRACE */
768  return SQLITE_IOERR_SHORT_READ;
769  }
770 }
int lastErrno
Definition: tkeyvfs.cc:106
static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt)
static int unixSectorSize ( sqlite3_file *  NotUsed)
static

Definition at line 1116 of file tkeyvfs_noroot.cc.

1117 {
1118  UNUSED_PARAMETER(NotUsed);
1119 #if TKEYVFS_TRACE
1120  fprintf(stderr, "Begin unixSectorSize ...\n");
1121 #endif /* TKEYVFS_TRACE */
1122 #if TKEYVFS_TRACE
1123  fprintf(stderr, "End unixSectorSize ...\n");
1124 #endif /* TKEYVFS_TRACE */
1126 }
#define UNUSED_PARAMETER(x)
#define SQLITE_DEFAULT_SECTOR_SIZE
static int unixSetSystemCall ( sqlite3_vfs *  pNotUsed,
const char *  zName,
sqlite3_syscall_ptr  pNewFunc 
)
static

Definition at line 1637 of file tkeyvfs_noroot.cc.

1642 {
1643  unsigned int i;
1644  int rc = SQLITE_NOTFOUND;
1645  UNUSED_PARAMETER(pNotUsed);
1646 #if TKEYVFS_TRACE
1647  fprintf(stderr, "Begin unixSetSystemCall ...\n");
1648 #endif /* TKEYVFS_TRACE */
1649  if (zName == 0) {
1650  /* If no zName is given, restore all system calls to their default
1651  ** settings and return nullptr
1652  */
1653  rc = SQLITE_OK;
1654  for (i = 0; i < sizeof(aSyscall) / sizeof(aSyscall[0]); i++) {
1655  if (aSyscall[i].pDefault) {
1657  }
1658  }
1659  } else {
1660  /* If zName is specified, operate on only the one system call
1661  ** specified.
1662  */
1663  for (i = 0; i < sizeof(aSyscall) / sizeof(aSyscall[0]); i++) {
1664  if (strcmp(zName, aSyscall[i].zName) == 0) {
1665  if (aSyscall[i].pDefault == 0) {
1667  }
1668  rc = SQLITE_OK;
1669  if (pNewFunc == 0) {
1670  pNewFunc = aSyscall[i].pDefault;
1671  }
1672  aSyscall[i].pCurrent = pNewFunc;
1673  break;
1674  }
1675  }
1676  }
1677 #if TKEYVFS_TRACE
1678  fprintf(stderr, "End unixSetSystemCall ...\n");
1679 #endif /* TKEYVFS_TRACE */
1680  return rc;
1681 }
sqlite3_syscall_ptr pDefault
Definition: tkeyvfs.cc:249
sqlite3_syscall_ptr pCurrent
Definition: tkeyvfs.cc:248
static struct unix_syscall aSyscall[]
#define UNUSED_PARAMETER(x)
static int unixSleep ( sqlite3_vfs *  NotUsed,
int  microseconds 
)
static

Definition at line 1550 of file tkeyvfs_noroot.cc.

1551 {
1552  UNUSED_PARAMETER(NotUsed);
1553 #if TKEYVFS_TRACE
1554  fprintf(stderr, "Begin unixSleep ...\n");
1555 #endif /* TKEYVFS_TRACE */
1556  usleep(microseconds);
1557 #if TKEYVFS_TRACE
1558  fprintf(stderr, "End unixSleep ...\n");
1559 #endif /* TKEYVFS_TRACE */
1560  return microseconds;
1561 }
#define UNUSED_PARAMETER(x)
static int unixSync ( sqlite3_file *  id,
int  flags 
)
static

Definition at line 918 of file tkeyvfs_noroot.cc.

919 {
920  UNUSED_PARAMETER2(id, flags);
921 #if TKEYVFS_TRACE
922  fprintf(stderr, "Begin unixSync ...\n");
923  if (((unixFile*)id)->zPath) {
924  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
925  }
926 #endif /* TKEYVFS_TRACE */
927 #if TKEYVFS_TRACE
928  fprintf(stderr, "End unixSync ...\n");
929 #endif /* TKEYVFS_TRACE */
930  return SQLITE_OK;
931 }
#define UNUSED_PARAMETER2(x, y)
static int unixTruncate ( sqlite3_file *  id,
i64  nByte 
)
static

Definition at line 836 of file tkeyvfs_noroot.cc.

837 {
838  unixFile* pFile = (unixFile*)id;
839  int rc;
840 #if TKEYVFS_TRACE
841  fprintf(stderr, "Begin unixTruncate ...\n");
842  if (((unixFile*)id)->zPath) {
843  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
844  }
845  fprintf(stderr, "nByte: 0x%016lx\n", (unsigned long long)nByte);
846 #endif /* TKEYVFS_TRACE */
847  /* If the user has configured a chunk-size for this file, truncate the
848  ** file so that it consists of an integer number of chunks (i.e. the
849  ** actual file size after the operation may be larger than the requested
850  ** size).
851  */
852  if (pFile->szChunk) {
853  nByte = ((nByte + pFile->szChunk - 1) / pFile->szChunk) * pFile->szChunk;
854  }
855  if (nByte == 0) {
856  free(pFile->pBuf);
857  pFile->pBuf = (char*)calloc(1, MEMPAGE);
858  if (pFile->pBuf == nullptr) {
859  pFile->bufAllocated = 0;
860  pFile->fileSize = 0;
861  pFile->lastErrno = errno;
862 #if TKEYVFS_TRACE
863  fprintf(stderr, "End unixTruncate ...\n");
864 #endif /* TKEYVFS_TRACE */
865  return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
866  }
867  pFile->bufAllocated = MEMPAGE;
868  pFile->fileSize = 0;
869  } else {
870  i64 newBufSize =
871  ((nByte + (i64)(MEMPAGE - 1)) / ((i64)MEMPAGE)) * ((i64)MEMPAGE);
872  i64 zeroCnt = newBufSize - nByte;
873  char* pNewBuf = (char*)realloc((void*)pFile->pBuf, (size_t)newBufSize);
874  if (pNewBuf == nullptr) {
875  pFile->lastErrno = errno;
876 #if TKEYVFS_TRACE
877  fprintf(stderr, "End unixTruncate ...\n");
878 #endif /* TKEYVFS_TRACE */
879  return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
880  }
881  (void*)memset((void*)(pNewBuf + nByte), 0, (size_t)zeroCnt);
882  pFile->pBuf = pNewBuf;
883  pFile->bufAllocated = newBufSize;
884  pFile->fileSize = nByte;
885  }
886  /* If we are doing a normal write to a database file (as opposed to
887  ** doing a hot-journal rollback or a write to some file other than a
888  ** normal database file) and we truncate the file to zero length,
889  ** that effectively updates the change counter. This might happen
890  ** when restoring a database using the backup API from a zero-length
891  ** source.
892  */
893  if (pFile->inNormalWrite && (nByte == 0)) {
894  pFile->transCntrChng = 1;
895  }
896 #if TKEYVFS_TRACE
897  fprintf(stderr, "End unixTruncate ...\n");
898 #endif /* TKEYVFS_TRACE */
899  return SQLITE_OK;
900 }
#define unixLogError(a, b, c)
sqlite_int64 i64
Definition: tkeyvfs.cc:34
unsigned char transCntrChng
Definition: tkeyvfs.cc:116
char * pBuf
Definition: tkeyvfs.cc:102
#define MEMPAGE
sqlite_int64 i64
unsigned char inNormalWrite
Definition: tkeyvfs.cc:118
i64 bufAllocated
Definition: tkeyvfs.cc:103
int lastErrno
Definition: tkeyvfs.cc:106
const char * zPath
Definition: tkeyvfs.cc:107
int szChunk
Definition: tkeyvfs.cc:108
i64 fileSize
Definition: tkeyvfs.cc:104
static int unixWrite ( sqlite3_file *  id,
const void *  pBuf,
int  amt,
sqlite3_int64  offset 
)
static

Definition at line 777 of file tkeyvfs_noroot.cc.

778 {
779  unixFile* pFile = (unixFile*)id;
780  int wrote = 0;
781 #if TKEYVFS_TRACE
782  fprintf(stderr, "Begin unixWrite ...\n");
783  if (((unixFile*)id)->zPath) {
784  fprintf(stderr, "filename: %s\n", ((unixFile*)id)->zPath);
785  }
786  fprintf(
787  stderr, "offset: 0x%016lx amt: 0x%08x\n", (unsigned long long)offset, amt);
788 #endif /* TKEYVFS_TRACE */
789  /* If we are doing a normal write to a database file (as opposed to
790  ** doing a hot-journal rollback or a write to some file other than a
791  ** normal database file) then record the fact that the database
792  ** has changed. If the transaction counter is modified, record that
793  ** fact too.
794  */
795  if (pFile->inNormalWrite) {
796  pFile->dbUpdate = 1; /* The database has been modified */
797  if ((offset <= 24) && (offset + amt >= 27)) {
798  int rc;
799  char oldCntr[4];
800  rc = seekAndRead(pFile, 24, oldCntr, 4);
801  if (rc != 4 || memcmp(oldCntr, &((char*)pBuf)[24 - offset], 4) != 0) {
802  pFile->transCntrChng = 1; /* The transaction counter has changed */
803  }
804  }
805  }
806  while ((amt > 0) && ((wrote = seekAndWrite(pFile, offset, pBuf, amt)) > 0)) {
807  amt -= wrote;
808  offset += wrote;
809  pBuf = &((char*)pBuf)[wrote];
810  }
811  if (amt > 0) {
812  if (wrote < 0) {
813  /* lastErrno set by seekAndWrite */
814 #if TKEYVFS_TRACE
815  fprintf(stderr, "End unixWrite ...\n");
816 #endif /* TKEYVFS_TRACE */
817  return SQLITE_IOERR_WRITE;
818  } else {
819  pFile->lastErrno = 0; /* not a system error */
820 #if TKEYVFS_TRACE
821  fprintf(stderr, "End unixWrite ...\n");
822 #endif /* TKEYVFS_TRACE */
823  return SQLITE_FULL;
824  }
825  }
826 #if TKEYVFS_TRACE
827  fprintf(stderr, "End unixWrite ...\n");
828 #endif /* TKEYVFS_TRACE */
829  return SQLITE_OK;
830 }
unsigned char transCntrChng
Definition: tkeyvfs.cc:116
static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt)
unsigned char inNormalWrite
Definition: tkeyvfs.cc:118
int lastErrno
Definition: tkeyvfs.cc:106
unsigned char dbUpdate
Definition: tkeyvfs.cc:117
static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt)

Variable Documentation

struct unix_syscall aSyscall[]
static
TFile* gRootFile
static

Definition at line 75 of file tkeyvfs_noroot.cc.

const sqlite3_io_methods*(*const nolockIoFinder) (const char *, unixFile *p)
static
Initial value:
=
static const sqlite3_io_methods * nolockIoFinderImpl(const char *z, unixFile *p)

Definition at line 363 of file tkeyvfs_noroot.cc.

const sqlite3_io_methods nolockIoMethods
static
Initial value:
= {
1,
}
static int nolockLock(sqlite3_file *NotUsed, int NotUsed2)
static int unixTruncate(sqlite3_file *id, i64 nByte)
static int unixWrite(sqlite3_file *id, const void *pBuf, int amt, sqlite3_int64 offset)
static int unixRead(sqlite3_file *id, void *pBuf, int amt, sqlite3_int64 offset)
static int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut)
static int unixSync(sqlite3_file *id, int flags)
static int nolockClose(sqlite3_file *id)
static int unixDeviceCharacteristics(sqlite3_file *NotUsed)
static int unixFileSize(sqlite3_file *id, i64 *pSize)
static int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2)
static int unixSectorSize(sqlite3_file *NotUsed)
static int unixFileControl(sqlite3_file *id, int op, void *pArg)

Definition at line 333 of file tkeyvfs_noroot.cc.

void(*)(void) unixDlSym(sqlite3_vfs *NotUsed, void *p, const char *zSym)
static

Definition at line 193 of file tkeyvfs_noroot.cc.