os_unix.c File Reference

Go to the source code of this file.

Classes

struct  unixFile
struct  lockKey
struct  lockInfo
struct  openKey
struct  openCnt

Defines

#define SQLITE_ENABLE_LOCKING_STYLE   0
#define _LARGE_FILE   1
#define _FILE_OFFSET_BITS   64
#define _LARGEFILE_SOURCE   1
#define MAX_PATHNAME   512
#define threadid   0
#define SET_THREADID(X)
#define CHECK_THREADID(X)   0
#define LOCKING_STYLE_POSIX   1
#define LOCKING_STYLE_NONE   2
#define LOCKING_STYLE_DOTFILE   3
#define LOCKING_STYLE_FLOCK   4
#define LOCKING_STYLE_AFP   5
#define IS_LOCK_ERROR(x)   ((x != SQLITE_OK) && (x != SQLITE_BUSY))
#define transferOwnership(X)   SQLITE_OK
#define fdatasync   fsync
#define HAVE_FULLFSYNC   0
#define IOMETHODS(xClose, xLock, xUnlock, xCheckReservedLock)
#define UNIXVFS(zVfsName, pVfsAppData)

Typedefs

typedef struct unixFile unixFile
typedef void nolockLockingContext

Functions

static void enterMutex (void)
static void leaveMutex (void)
static void releaseLockInfo (struct lockInfo *pLock)
static void releaseOpenCnt (struct openCnt *pOpen)
static int detectLockingStyle (sqlite3_vfs *pVfs, const char *filePath, int fd)
static int findLockInfo (int fd, struct lockInfo **ppLock, struct openCnt **ppOpen)
static int seekAndRead (unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt)
static int unixRead (sqlite3_file *id, void *pBuf, int amt, sqlite3_int64 offset)
static int seekAndWrite (unixFile *id, i64 offset, const void *pBuf, int cnt)
static int unixWrite (sqlite3_file *id, const void *pBuf, int amt, sqlite3_int64 offset)
static int full_fsync (int fd, int fullSync, int dataOnly)
static int unixSync (sqlite3_file *id, int flags)
static int unixTruncate (sqlite3_file *id, i64 nByte)
static int unixFileSize (sqlite3_file *id, i64 *pSize)
static int sqliteErrorFromPosixError (int posixError, int sqliteIOErr)
static int unixCheckReservedLock (sqlite3_file *id, int *pResOut)
static int unixLock (sqlite3_file *id, int locktype)
static int unixUnlock (sqlite3_file *id, int locktype)
static int closeUnixFile (sqlite3_file *id)
static int unixClose (sqlite3_file *id)
static int nolockCheckReservedLock (sqlite3_file *id, int *pResOut)
static int nolockLock (sqlite3_file *id, int locktype)
static int nolockUnlock (sqlite3_file *id, int locktype)
static int nolockClose (sqlite3_file *id)
static int unixFileControl (sqlite3_file *id, int op, void *pArg)
static int unixSectorSize (sqlite3_file *id)
static int unixDeviceCharacteristics (sqlite3_file *id)
static int fillInUnixFile (sqlite3_vfs *pVfs, int h, int dirfd, sqlite3_file *pId, const char *zFilename, int noLock)
static int openDirectory (const char *zFilename, int *pFd)
static int getTempname (int nBuf, char *zBuf)
static int unixOpen (sqlite3_vfs *pVfs, const char *zPath, sqlite3_file *pFile, int flags, int *pOutFlags)
static int unixDelete (sqlite3_vfs *pVfs, const char *zPath, int dirSync)
static int unixAccess (sqlite3_vfs *pVfs, 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 *pVfs, const char *zFilename)
static void unixDlError (sqlite3_vfs *pVfs, int nBuf, char *zBufOut)
static void * unixDlSym (sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol)
static void unixDlClose (sqlite3_vfs *pVfs, void *pHandle)
static int unixRandomness (sqlite3_vfs *pVfs, int nBuf, char *zBuf)
static int unixSleep (sqlite3_vfs *pVfs, int microseconds)
static int unixCurrentTime (sqlite3_vfs *pVfs, double *prNow)
static int unixGetLastError (sqlite3_vfs *pVfs, int nBuf, char *zBuf)
int sqlite3_os_init (void)
int sqlite3_os_end (void)

Variables

static struct lockInfolockList = 0
static struct openCntopenList = 0

Define Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 57 of file os_unix.c.

#define _LARGE_FILE   1

Definition at line 55 of file os_unix.c.

#define _LARGEFILE_SOURCE   1

Definition at line 59 of file os_unix.c.

#define CHECK_THREADID (  )     0

Definition at line 192 of file os_unix.c.

Referenced by unixUnlock().

#define fdatasync   fsync

Definition at line 991 of file os_unix.c.

#define HAVE_FULLFSYNC   0

Definition at line 1002 of file os_unix.c.

#define IOMETHODS ( xClose,
xLock,
xUnlock,
xCheckReservedLock   ) 
Value:
{    \
    1,                          /* iVersion */                           \
    xClose,                     /* xClose */                             \
    unixRead,                   /* xRead */                              \
    unixWrite,                  /* xWrite */                             \
    unixTruncate,               /* xTruncate */                          \
    unixSync,                   /* xSync */                              \
    unixFileSize,               /* xFileSize */                          \
    xLock,                      /* xLock */                              \
    xUnlock,                    /* xUnlock */                            \
    xCheckReservedLock,         /* xCheckReservedLock */                 \
    unixFileControl,            /* xFileControl */                       \
    unixSectorSize,             /* xSectorSize */                        \
    unixDeviceCharacteristics   /* xDeviceCapabilities */                \
  }
#define IS_LOCK_ERROR (  )     ((x != SQLITE_OK) && (x != SQLITE_BUSY))

Definition at line 387 of file os_unix.c.

Referenced by unixLock(), and unixUnlock().

#define LOCKING_STYLE_AFP   5

Definition at line 381 of file os_unix.c.

Referenced by detectLockingStyle(), fillInUnixFile(), and sqlite3_os_init().

#define LOCKING_STYLE_DOTFILE   3

Definition at line 379 of file os_unix.c.

Referenced by detectLockingStyle(), fillInUnixFile(), and sqlite3_os_init().

#define LOCKING_STYLE_FLOCK   4

Definition at line 380 of file os_unix.c.

Referenced by detectLockingStyle(), fillInUnixFile(), and sqlite3_os_init().

#define LOCKING_STYLE_NONE   2

Definition at line 378 of file os_unix.c.

Referenced by detectLockingStyle(), fillInUnixFile(), and sqlite3_os_init().

#define LOCKING_STYLE_POSIX   1

Definition at line 377 of file os_unix.c.

Referenced by detectLockingStyle(), fillInUnixFile(), and sqlite3_os_init().

#define MAX_PATHNAME   512

Definition at line 98 of file os_unix.c.

#define SET_THREADID (  ) 

Definition at line 191 of file os_unix.c.

Referenced by fillInUnixFile().

#define SQLITE_ENABLE_LOCKING_STYLE   0

Definition at line 37 of file os_unix.c.

#define threadid   0

Definition at line 167 of file os_unix.c.

#define transferOwnership (  )     SQLITE_OK

Definition at line 861 of file os_unix.c.

Referenced by unixLock().

#define UNIXVFS ( zVfsName,
pVfsAppData   ) 
Value:
{                  \
    1,                    /* iVersion */                    \
    sizeof(unixFile),     /* szOsFile */                    \
    MAX_PATHNAME,         /* mxPathname */                  \
    0,                    /* pNext */                       \
    zVfsName,             /* zName */                       \
    (void *)pVfsAppData,  /* 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 */               \
  }

Typedef Documentation

typedef void nolockLockingContext

Definition at line 2281 of file os_unix.c.

typedef struct unixFile unixFile

Definition at line 105 of file os_unix.c.


Function Documentation

static int closeUnixFile ( sqlite3_file id  )  [static]

Definition at line 1640 of file os_unix.c.

References unixFile::dirfd, unixFile::h, OpenCounter, OSTRACE2, and SQLITE_OK.

Referenced by nolockClose(), and unixClose().

static int detectLockingStyle ( sqlite3_vfs pVfs,
const char *  filePath,
int  fd 
) [static]
static void enterMutex ( void   )  [static]
static int fillInUnixFile ( sqlite3_vfs pVfs,
int  h,
int  dirfd,
sqlite3_file pId,
const char *  zFilename,
int  noLock 
) [static]
static int findLockInfo ( int  fd,
struct lockInfo **  ppLock,
struct openCnt **  ppOpen 
) [static]
static int full_fsync ( int  fd,
int  fullSync,
int  dataOnly 
) [static]

Definition at line 1017 of file os_unix.c.

References fdatasync, and SQLITE_OK.

Referenced by unixSync().

static int getTempname ( int  nBuf,
char *  zBuf 
) [static]
static void leaveMutex ( void   )  [static]
static int nolockCheckReservedLock ( sqlite3_file id,
int *  pResOut 
) [static]

Definition at line 2283 of file os_unix.c.

References SQLITE_OK.

Referenced by fillInUnixFile().

static int nolockClose ( sqlite3_file id  )  [static]

Definition at line 2299 of file os_unix.c.

References closeUnixFile().

Referenced by fillInUnixFile().

static int nolockLock ( sqlite3_file id,
int  locktype 
) [static]

Definition at line 2288 of file os_unix.c.

References SQLITE_OK.

Referenced by fillInUnixFile().

static int nolockUnlock ( sqlite3_file id,
int  locktype 
) [static]

Definition at line 2292 of file os_unix.c.

References SQLITE_OK.

Referenced by fillInUnixFile().

static int openDirectory ( const char *  zFilename,
int *  pFd 
) [static]

Definition at line 2482 of file os_unix.c.

References MAX_PATHNAME, O_BINARY, OSTRACE3, sqlite3_snprintf(), SQLITE_CANTOPEN, and SQLITE_OK.

Referenced by unixDelete(), and unixOpen().

static void releaseLockInfo ( struct lockInfo pLock  )  [static]

Definition at line 557 of file os_unix.c.

References lockInfo::nRef, lockInfo::pNext, lockInfo::pPrev, and sqlite3_free().

Referenced by findLockInfo(), and unixClose().

static void releaseOpenCnt ( struct openCnt pOpen  )  [static]

Definition at line 580 of file os_unix.c.

References openCnt::aPending, openCnt::nRef, openCnt::pNext, openCnt::pPrev, and sqlite3_free().

Referenced by unixClose().

static int seekAndRead ( unixFile id,
sqlite3_int64  offset,
void *  pBuf,
int  cnt 
) [static]

Definition at line 874 of file os_unix.c.

References unixFile::h, OSTRACE5, SimulateIOError, TIMER_ELAPSED, TIMER_END, and TIMER_START.

Referenced by unixRead().

static int seekAndWrite ( unixFile id,
i64  offset,
const void *  pBuf,
int  cnt 
) [static]

Definition at line 926 of file os_unix.c.

References unixFile::h, OSTRACE5, TIMER_ELAPSED, TIMER_END, and TIMER_START.

Referenced by unixWrite().

int sqlite3_os_end ( void   ) 

Definition at line 3004 of file os_unix.c.

References SQLITE_OK.

int sqlite3_os_init ( void   ) 
static int sqliteErrorFromPosixError ( int  posixError,
int  sqliteIOErr 
) [static]
static int unixAccess ( sqlite3_vfs pVfs,
const char *  zPath,
int  flags,
int *  pResOut 
) [static]
static int unixCheckReservedLock ( sqlite3_file id,
int *  pResOut 
) [static]
static int unixClose ( sqlite3_file id  )  [static]
static int unixCurrentTime ( sqlite3_vfs pVfs,
double *  prNow 
) [static]

Definition at line 2931 of file os_unix.c.

static int unixDelete ( sqlite3_vfs pVfs,
const char *  zPath,
int  dirSync 
) [static]
static int unixDeviceCharacteristics ( sqlite3_file id  )  [static]

Definition at line 2334 of file os_unix.c.

static void unixDlClose ( sqlite3_vfs pVfs,
void *  pHandle 
) [static]

Definition at line 2847 of file os_unix.c.

static void unixDlError ( sqlite3_vfs pVfs,
int  nBuf,
char *  zBufOut 
) [static]

Definition at line 2835 of file os_unix.c.

References enterMutex(), leaveMutex(), and sqlite3_snprintf().

static void* unixDlOpen ( sqlite3_vfs pVfs,
const char *  zFilename 
) [static]

Definition at line 2824 of file os_unix.c.

static void* unixDlSym ( sqlite3_vfs pVfs,
void *  pHandle,
const char *  zSymbol 
) [static]

Definition at line 2844 of file os_unix.c.

static int unixFileControl ( sqlite3_file id,
int  op,
void *  pArg 
) [static]

Definition at line 2307 of file os_unix.c.

References SQLITE_ERROR, SQLITE_FCNTL_LOCKSTATE, and SQLITE_OK.

static int unixFileSize ( sqlite3_file id,
i64 pSize 
) [static]

Definition at line 1145 of file os_unix.c.

References SimulateIOError, SQLITE_IOERR_FSTAT, and SQLITE_OK.

static int unixFullPathname ( sqlite3_vfs pVfs,
const char *  zPath,
int  nOut,
char *  zOut 
) [static]
static int unixGetLastError ( sqlite3_vfs pVfs,
int  nBuf,
char *  zBuf 
) [static]

Definition at line 2949 of file os_unix.c.

static int unixLock ( sqlite3_file id,
int  locktype 
) [static]
static int unixOpen ( sqlite3_vfs pVfs,
const char *  zPath,
sqlite3_file pFile,
int  flags,
int *  pOutFlags 
) [static]
static int unixRandomness ( sqlite3_vfs pVfs,
int  nBuf,
char *  zBuf 
) [static]

Definition at line 2860 of file os_unix.c.

static int unixRead ( sqlite3_file id,
void *  pBuf,
int  amt,
sqlite3_int64  offset 
) [static]

Definition at line 902 of file os_unix.c.

References seekAndRead(), SQLITE_IOERR_READ, SQLITE_IOERR_SHORT_READ, and SQLITE_OK.

static int unixSectorSize ( sqlite3_file id  )  [static]

Definition at line 2327 of file os_unix.c.

References SQLITE_DEFAULT_SECTOR_SIZE.

static int unixSleep ( sqlite3_vfs pVfs,
int  microseconds 
) [static]

Definition at line 2907 of file os_unix.c.

static int unixSync ( sqlite3_file id,
int  flags 
) [static]
static int unixTruncate ( sqlite3_file id,
i64  nByte 
) [static]

Definition at line 1130 of file os_unix.c.

References SimulateIOError, SQLITE_IOERR_TRUNCATE, and SQLITE_OK.

static int unixUnlock ( sqlite3_file id,
int  locktype 
) [static]
static int unixWrite ( sqlite3_file id,
const void *  pBuf,
int  amt,
sqlite3_int64  offset 
) [static]

Variable Documentation

struct lockInfo* lockList = 0 [static]

Definition at line 359 of file os_unix.c.

struct openCnt* openList = 0 [static]

Definition at line 360 of file os_unix.c.


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:50:00 2011 by Doxygen 1.6.1