Fossil SCM

First attempt in makeing fossil work on VxWorks. Based on feedback by Andy Ling.

jan.nijtmans 2014-07-08 10:48 UTC trunk
Commit 18ae9fddb815e90bd5a8541fc7175af877ef9081
1 file changed +15 -8
+15 -8
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -23818,11 +23818,11 @@
2381823818
#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
2381923819
#include <sys/mman.h>
2382023820
#endif
2382123821
2382223822
23823
-#if SQLITE_ENABLE_LOCKING_STYLE
23823
+#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
2382423824
# include <sys/ioctl.h>
2382523825
# if OS_VXWORKS
2382623826
# include <semaphore.h>
2382723827
# include <limits.h>
2382823828
# else
@@ -24246,11 +24246,15 @@
2424624246
** On some systems, calls to fchown() will trigger a message in a security
2424724247
** log if they come from non-root processes. So avoid calling fchown() if
2424824248
** we are not running as root.
2424924249
*/
2425024250
static int posixFchown(int fd, uid_t uid, gid_t gid){
24251
+#if OS_VXWORKS
24252
+ return 0;
24253
+#else
2425124254
return geteuid() ? 0 : fchown(fd,uid,gid);
24255
+#endif
2425224256
}
2425324257
2425424258
/* Forward reference */
2425524259
static int openDirectory(const char*, int*);
2425624260
static int unixGetpagesize(void);
@@ -24302,11 +24306,11 @@
2430224306
#define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
2430324307
2430424308
{ "read", (sqlite3_syscall_ptr)read, 0 },
2430524309
#define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
2430624310
24307
-#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
24311
+#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
2430824312
{ "pread", (sqlite3_syscall_ptr)pread, 0 },
2430924313
#else
2431024314
{ "pread", (sqlite3_syscall_ptr)0, 0 },
2431124315
#endif
2431224316
#define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
@@ -25231,13 +25235,18 @@
2523125235
2523225236
/*
2523325237
** Return TRUE if pFile has been renamed or unlinked since it was first opened.
2523425238
*/
2523525239
static int fileHasMoved(unixFile *pFile){
25240
+#if OS_VXWORKS
25241
+ return pFile->pInode!=0 &&
25242
+ (pFile->pId!=pFile->pInode->fileId.pId);
25243
+#else
2523625244
struct stat buf;
2523725245
return pFile->pInode!=0 &&
2523825246
(osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino);
25247
+#endif
2523925248
}
2524025249
2524125250
2524225251
/*
2524325252
** Check a unixFile that is a database. Verify the following:
@@ -26376,11 +26385,10 @@
2637626385
}
2637726386
2637826387
/* Otherwise see if some other process holds it. */
2637926388
if( !reserved ){
2638026389
sem_t *pSem = pFile->pInode->pSem;
26381
- struct stat statBuf;
2638226390
2638326391
if( sem_trywait(pSem)==-1 ){
2638426392
int tErrno = errno;
2638526393
if( EAGAIN != tErrno ){
2638626394
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);
@@ -26429,11 +26437,10 @@
2642926437
** This routine will only increase a lock. Use the sqlite3OsUnlock()
2643026438
** routine to lower a locking level.
2643126439
*/
2643226440
static int semLock(sqlite3_file *id, int eFileLock) {
2643326441
unixFile *pFile = (unixFile*)id;
26434
- int fd;
2643526442
sem_t *pSem = pFile->pInode->pSem;
2643626443
int rc = SQLITE_OK;
2643726444
2643826445
/* if we already have a lock, it is exclusive.
2643926446
** Just adjust level and punt on outta here. */
@@ -29560,14 +29567,14 @@
2956029567
int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
2956129568
int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE);
2956229569
int isCreate = (flags & SQLITE_OPEN_CREATE);
2956329570
int isReadonly = (flags & SQLITE_OPEN_READONLY);
2956429571
int isReadWrite = (flags & SQLITE_OPEN_READWRITE);
29565
-#if SQLITE_ENABLE_LOCKING_STYLE
29572
+#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
2956629573
int isAutoProxy = (flags & SQLITE_OPEN_AUTOPROXY);
2956729574
#endif
29568
-#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
29575
+#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
2956929576
struct statfs fsInfo;
2957029577
#endif
2957129578
2957229579
/* If creating a master or main-file journal, this function will open
2957329580
** a file-descriptor on the directory too. The first time unixSync()
@@ -29729,11 +29736,11 @@
2972929736
#endif
2973029737
2973129738
noLock = eType!=SQLITE_OPEN_MAIN_DB;
2973229739
2973329740
29734
-#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
29741
+#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
2973529742
if( fstatfs(fd, &fsInfo) == -1 ){
2973629743
((unixFile*)pFile)->lastErrno = errno;
2973729744
robust_close(p, fd, __LINE__);
2973829745
return SQLITE_IOERR_ACCESS;
2973929746
}
@@ -29747,11 +29754,11 @@
2974729754
if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
2974829755
if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
2974929756
if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC;
2975029757
if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
2975129758
29752
-#if SQLITE_ENABLE_LOCKING_STYLE
29759
+#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
2975329760
#if SQLITE_PREFER_PROXY_LOCKING
2975429761
isAutoProxy = 1;
2975529762
#endif
2975629763
if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){
2975729764
char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING");
2975829765
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -23818,11 +23818,11 @@
23818 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
23819 #include <sys/mman.h>
23820 #endif
23821
23822
23823 #if SQLITE_ENABLE_LOCKING_STYLE
23824 # include <sys/ioctl.h>
23825 # if OS_VXWORKS
23826 # include <semaphore.h>
23827 # include <limits.h>
23828 # else
@@ -24246,11 +24246,15 @@
24246 ** On some systems, calls to fchown() will trigger a message in a security
24247 ** log if they come from non-root processes. So avoid calling fchown() if
24248 ** we are not running as root.
24249 */
24250 static int posixFchown(int fd, uid_t uid, gid_t gid){
 
 
 
24251 return geteuid() ? 0 : fchown(fd,uid,gid);
 
24252 }
24253
24254 /* Forward reference */
24255 static int openDirectory(const char*, int*);
24256 static int unixGetpagesize(void);
@@ -24302,11 +24306,11 @@
24302 #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
24303
24304 { "read", (sqlite3_syscall_ptr)read, 0 },
24305 #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
24306
24307 #if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
24308 { "pread", (sqlite3_syscall_ptr)pread, 0 },
24309 #else
24310 { "pread", (sqlite3_syscall_ptr)0, 0 },
24311 #endif
24312 #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
@@ -25231,13 +25235,18 @@
25231
25232 /*
25233 ** Return TRUE if pFile has been renamed or unlinked since it was first opened.
25234 */
25235 static int fileHasMoved(unixFile *pFile){
 
 
 
 
25236 struct stat buf;
25237 return pFile->pInode!=0 &&
25238 (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino);
 
25239 }
25240
25241
25242 /*
25243 ** Check a unixFile that is a database. Verify the following:
@@ -26376,11 +26385,10 @@
26376 }
26377
26378 /* Otherwise see if some other process holds it. */
26379 if( !reserved ){
26380 sem_t *pSem = pFile->pInode->pSem;
26381 struct stat statBuf;
26382
26383 if( sem_trywait(pSem)==-1 ){
26384 int tErrno = errno;
26385 if( EAGAIN != tErrno ){
26386 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);
@@ -26429,11 +26437,10 @@
26429 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
26430 ** routine to lower a locking level.
26431 */
26432 static int semLock(sqlite3_file *id, int eFileLock) {
26433 unixFile *pFile = (unixFile*)id;
26434 int fd;
26435 sem_t *pSem = pFile->pInode->pSem;
26436 int rc = SQLITE_OK;
26437
26438 /* if we already have a lock, it is exclusive.
26439 ** Just adjust level and punt on outta here. */
@@ -29560,14 +29567,14 @@
29560 int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
29561 int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE);
29562 int isCreate = (flags & SQLITE_OPEN_CREATE);
29563 int isReadonly = (flags & SQLITE_OPEN_READONLY);
29564 int isReadWrite = (flags & SQLITE_OPEN_READWRITE);
29565 #if SQLITE_ENABLE_LOCKING_STYLE
29566 int isAutoProxy = (flags & SQLITE_OPEN_AUTOPROXY);
29567 #endif
29568 #if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
29569 struct statfs fsInfo;
29570 #endif
29571
29572 /* If creating a master or main-file journal, this function will open
29573 ** a file-descriptor on the directory too. The first time unixSync()
@@ -29729,11 +29736,11 @@
29729 #endif
29730
29731 noLock = eType!=SQLITE_OPEN_MAIN_DB;
29732
29733
29734 #if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
29735 if( fstatfs(fd, &fsInfo) == -1 ){
29736 ((unixFile*)pFile)->lastErrno = errno;
29737 robust_close(p, fd, __LINE__);
29738 return SQLITE_IOERR_ACCESS;
29739 }
@@ -29747,11 +29754,11 @@
29747 if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
29748 if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
29749 if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC;
29750 if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
29751
29752 #if SQLITE_ENABLE_LOCKING_STYLE
29753 #if SQLITE_PREFER_PROXY_LOCKING
29754 isAutoProxy = 1;
29755 #endif
29756 if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){
29757 char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING");
29758
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -23818,11 +23818,11 @@
23818 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
23819 #include <sys/mman.h>
23820 #endif
23821
23822
23823 #if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
23824 # include <sys/ioctl.h>
23825 # if OS_VXWORKS
23826 # include <semaphore.h>
23827 # include <limits.h>
23828 # else
@@ -24246,11 +24246,15 @@
24246 ** On some systems, calls to fchown() will trigger a message in a security
24247 ** log if they come from non-root processes. So avoid calling fchown() if
24248 ** we are not running as root.
24249 */
24250 static int posixFchown(int fd, uid_t uid, gid_t gid){
24251 #if OS_VXWORKS
24252 return 0;
24253 #else
24254 return geteuid() ? 0 : fchown(fd,uid,gid);
24255 #endif
24256 }
24257
24258 /* Forward reference */
24259 static int openDirectory(const char*, int*);
24260 static int unixGetpagesize(void);
@@ -24302,11 +24306,11 @@
24306 #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent)
24307
24308 { "read", (sqlite3_syscall_ptr)read, 0 },
24309 #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
24310
24311 #if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
24312 { "pread", (sqlite3_syscall_ptr)pread, 0 },
24313 #else
24314 { "pread", (sqlite3_syscall_ptr)0, 0 },
24315 #endif
24316 #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
@@ -25231,13 +25235,18 @@
25235
25236 /*
25237 ** Return TRUE if pFile has been renamed or unlinked since it was first opened.
25238 */
25239 static int fileHasMoved(unixFile *pFile){
25240 #if OS_VXWORKS
25241 return pFile->pInode!=0 &&
25242 (pFile->pId!=pFile->pInode->fileId.pId);
25243 #else
25244 struct stat buf;
25245 return pFile->pInode!=0 &&
25246 (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino);
25247 #endif
25248 }
25249
25250
25251 /*
25252 ** Check a unixFile that is a database. Verify the following:
@@ -26376,11 +26385,10 @@
26385 }
26386
26387 /* Otherwise see if some other process holds it. */
26388 if( !reserved ){
26389 sem_t *pSem = pFile->pInode->pSem;
 
26390
26391 if( sem_trywait(pSem)==-1 ){
26392 int tErrno = errno;
26393 if( EAGAIN != tErrno ){
26394 rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);
@@ -26429,11 +26437,10 @@
26437 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
26438 ** routine to lower a locking level.
26439 */
26440 static int semLock(sqlite3_file *id, int eFileLock) {
26441 unixFile *pFile = (unixFile*)id;
 
26442 sem_t *pSem = pFile->pInode->pSem;
26443 int rc = SQLITE_OK;
26444
26445 /* if we already have a lock, it is exclusive.
26446 ** Just adjust level and punt on outta here. */
@@ -29560,14 +29567,14 @@
29567 int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
29568 int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE);
29569 int isCreate = (flags & SQLITE_OPEN_CREATE);
29570 int isReadonly = (flags & SQLITE_OPEN_READONLY);
29571 int isReadWrite = (flags & SQLITE_OPEN_READWRITE);
29572 #if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
29573 int isAutoProxy = (flags & SQLITE_OPEN_AUTOPROXY);
29574 #endif
29575 #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
29576 struct statfs fsInfo;
29577 #endif
29578
29579 /* If creating a master or main-file journal, this function will open
29580 ** a file-descriptor on the directory too. The first time unixSync()
@@ -29729,11 +29736,11 @@
29736 #endif
29737
29738 noLock = eType!=SQLITE_OPEN_MAIN_DB;
29739
29740
29741 #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
29742 if( fstatfs(fd, &fsInfo) == -1 ){
29743 ((unixFile*)pFile)->lastErrno = errno;
29744 robust_close(p, fd, __LINE__);
29745 return SQLITE_IOERR_ACCESS;
29746 }
@@ -29747,11 +29754,11 @@
29754 if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
29755 if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
29756 if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC;
29757 if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
29758
29759 #if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
29760 #if SQLITE_PREFER_PROXY_LOCKING
29761 isAutoProxy = 1;
29762 #endif
29763 if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){
29764 char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING");
29765

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button