[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    [sqlite] [sqlite-users] -DSQLITE_ENABLE_LOCKING_STYLE=1 doesn't work on Linux/Cygwin
From:       Jan Nijtmans <jan.nijtmans () gmail ! com>
Date:       2013-08-29 21:45:17
Message-ID: CAO1jNwvdm4PrQGLbP4wyVLQoPaE1D9WfjF_m2uu7q_SBd-P9kA () mail ! gmail ! com
[Download RAW message or body]

The effect of SQLITE_ENABLE_LOCKING_STYLE=1 on
platforms other than VXWORKS or OSX is documented
to enable the flock locking style, which is available just fine
on Linux and Cygwin. So this should work fine:

$ gcc -c -DSQLITE_ENABLE_LOCKING_STYLE=1 -DSQLITE_OS_UNIX=1 sqlite3.c
sqlite3.c: In function ‘unixOpen’:
sqlite3.c:28619:17: error: storage size of ‘fsInfo’ isn’t known
sqlite3.c:28812:35: error: ‘MNT_LOCAL’ undeclared (first use in this function)
sqlite3.c:28812:35: note: each undeclared identifier is reported only
once for each function it appears in

I believe the inlined patch (see below) properly fixes this, although it's
only tested on Linux and Cygwin, not on VXWORKS and OSX

Regards,
        Jan Nijtmans

Index: src/os_unix.c
==================================================================
--- src/os_unix.c
+++ src/os_unix.c
@@ -227,14 +227,14 @@
 #endif
 #ifdef __QNXNTO__
   int sectorSize;                     /* Device sector size */
   int deviceCharacteristics;          /* Precomputed device characteristics */
 #endif
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
   int openFlags;                      /* The flags specified at open() */
 #endif
-#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
+#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE && OS_VXWORKS
   unsigned fsFlags;                   /* cached details from statfs() */
 #endif
 #if OS_VXWORKS
   struct vxworksFileId *pId;          /* Unique file ID */
 #endif
@@ -5565,14 +5565,14 @@
   int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);
   int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);
   int isCreate     = (flags & SQLITE_OPEN_CREATE);
   int isReadonly   = (flags & SQLITE_OPEN_READONLY);
   int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
   int isAutoProxy  = (flags & SQLITE_OPEN_AUTOPROXY);
 #endif
-#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
+#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE && OS_VXWORKS
   struct statfs fsInfo;
 #endif

   /* If creating a master or main-file journal, this function will open
   ** a file-descriptor on the directory too. The first time unixSync()
@@ -5709,20 +5709,20 @@
     zPath = zName;
 #else
     osUnlink(zName);
 #endif
   }
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
   else{
     p->openFlags = openFlags;
   }
 #endif

   noLock = eType!=SQLITE_OPEN_MAIN_DB;


-#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
+#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE && OS_VXWORKS
   if( fstatfs(fd, &fsInfo) == -1 ){
     ((unixFile*)pFile)->lastErrno = errno;
     robust_close(p, fd, __LINE__);
     return SQLITE_IOERR_ACCESS;
   }
@@ -5736,11 +5736,11 @@
   if( isReadonly )              ctrlFlags |= UNIXFILE_RDONLY;
   if( noLock )                  ctrlFlags |= UNIXFILE_NOLOCK;
   if( syncDir )                 ctrlFlags |= UNIXFILE_DIRSYNC;
   if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;

-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
 #if SQLITE_PREFER_PROXY_LOCKING
   isAutoProxy = 1;
 #endif
   if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){
     char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING");
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic