Fossil SCM
First attempt in makeing fossil work on VxWorks. Based on feedback by Andy Ling.
Commit
18ae9fddb815e90bd5a8541fc7175af877ef9081
Parent
6728a8bd0898123…
1 file changed
+15
-8
+15
-8
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -23818,11 +23818,11 @@ | ||
| 23818 | 23818 | #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 |
| 23819 | 23819 | #include <sys/mman.h> |
| 23820 | 23820 | #endif |
| 23821 | 23821 | |
| 23822 | 23822 | |
| 23823 | -#if SQLITE_ENABLE_LOCKING_STYLE | |
| 23823 | +#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS | |
| 23824 | 23824 | # include <sys/ioctl.h> |
| 23825 | 23825 | # if OS_VXWORKS |
| 23826 | 23826 | # include <semaphore.h> |
| 23827 | 23827 | # include <limits.h> |
| 23828 | 23828 | # else |
| @@ -24246,11 +24246,15 @@ | ||
| 24246 | 24246 | ** On some systems, calls to fchown() will trigger a message in a security |
| 24247 | 24247 | ** log if they come from non-root processes. So avoid calling fchown() if |
| 24248 | 24248 | ** we are not running as root. |
| 24249 | 24249 | */ |
| 24250 | 24250 | static int posixFchown(int fd, uid_t uid, gid_t gid){ |
| 24251 | +#if OS_VXWORKS | |
| 24252 | + return 0; | |
| 24253 | +#else | |
| 24251 | 24254 | return geteuid() ? 0 : fchown(fd,uid,gid); |
| 24255 | +#endif | |
| 24252 | 24256 | } |
| 24253 | 24257 | |
| 24254 | 24258 | /* Forward reference */ |
| 24255 | 24259 | static int openDirectory(const char*, int*); |
| 24256 | 24260 | static int unixGetpagesize(void); |
| @@ -24302,11 +24306,11 @@ | ||
| 24302 | 24306 | #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent) |
| 24303 | 24307 | |
| 24304 | 24308 | { "read", (sqlite3_syscall_ptr)read, 0 }, |
| 24305 | 24309 | #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent) |
| 24306 | 24310 | |
| 24307 | -#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE | |
| 24311 | +#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) | |
| 24308 | 24312 | { "pread", (sqlite3_syscall_ptr)pread, 0 }, |
| 24309 | 24313 | #else |
| 24310 | 24314 | { "pread", (sqlite3_syscall_ptr)0, 0 }, |
| 24311 | 24315 | #endif |
| 24312 | 24316 | #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent) |
| @@ -25231,13 +25235,18 @@ | ||
| 25231 | 25235 | |
| 25232 | 25236 | /* |
| 25233 | 25237 | ** Return TRUE if pFile has been renamed or unlinked since it was first opened. |
| 25234 | 25238 | */ |
| 25235 | 25239 | static int fileHasMoved(unixFile *pFile){ |
| 25240 | +#if OS_VXWORKS | |
| 25241 | + return pFile->pInode!=0 && | |
| 25242 | + (pFile->pId!=pFile->pInode->fileId.pId); | |
| 25243 | +#else | |
| 25236 | 25244 | struct stat buf; |
| 25237 | 25245 | return pFile->pInode!=0 && |
| 25238 | 25246 | (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); |
| 25247 | +#endif | |
| 25239 | 25248 | } |
| 25240 | 25249 | |
| 25241 | 25250 | |
| 25242 | 25251 | /* |
| 25243 | 25252 | ** Check a unixFile that is a database. Verify the following: |
| @@ -26376,11 +26385,10 @@ | ||
| 26376 | 26385 | } |
| 26377 | 26386 | |
| 26378 | 26387 | /* Otherwise see if some other process holds it. */ |
| 26379 | 26388 | if( !reserved ){ |
| 26380 | 26389 | sem_t *pSem = pFile->pInode->pSem; |
| 26381 | - struct stat statBuf; | |
| 26382 | 26390 | |
| 26383 | 26391 | if( sem_trywait(pSem)==-1 ){ |
| 26384 | 26392 | int tErrno = errno; |
| 26385 | 26393 | if( EAGAIN != tErrno ){ |
| 26386 | 26394 | rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK); |
| @@ -26429,11 +26437,10 @@ | ||
| 26429 | 26437 | ** This routine will only increase a lock. Use the sqlite3OsUnlock() |
| 26430 | 26438 | ** routine to lower a locking level. |
| 26431 | 26439 | */ |
| 26432 | 26440 | static int semLock(sqlite3_file *id, int eFileLock) { |
| 26433 | 26441 | unixFile *pFile = (unixFile*)id; |
| 26434 | - int fd; | |
| 26435 | 26442 | sem_t *pSem = pFile->pInode->pSem; |
| 26436 | 26443 | int rc = SQLITE_OK; |
| 26437 | 26444 | |
| 26438 | 26445 | /* if we already have a lock, it is exclusive. |
| 26439 | 26446 | ** Just adjust level and punt on outta here. */ |
| @@ -29560,14 +29567,14 @@ | ||
| 29560 | 29567 | int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); |
| 29561 | 29568 | int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE); |
| 29562 | 29569 | int isCreate = (flags & SQLITE_OPEN_CREATE); |
| 29563 | 29570 | int isReadonly = (flags & SQLITE_OPEN_READONLY); |
| 29564 | 29571 | int isReadWrite = (flags & SQLITE_OPEN_READWRITE); |
| 29565 | -#if SQLITE_ENABLE_LOCKING_STYLE | |
| 29572 | +#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS | |
| 29566 | 29573 | int isAutoProxy = (flags & SQLITE_OPEN_AUTOPROXY); |
| 29567 | 29574 | #endif |
| 29568 | -#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE | |
| 29575 | +#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) | |
| 29569 | 29576 | struct statfs fsInfo; |
| 29570 | 29577 | #endif |
| 29571 | 29578 | |
| 29572 | 29579 | /* If creating a master or main-file journal, this function will open |
| 29573 | 29580 | ** a file-descriptor on the directory too. The first time unixSync() |
| @@ -29729,11 +29736,11 @@ | ||
| 29729 | 29736 | #endif |
| 29730 | 29737 | |
| 29731 | 29738 | noLock = eType!=SQLITE_OPEN_MAIN_DB; |
| 29732 | 29739 | |
| 29733 | 29740 | |
| 29734 | -#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE | |
| 29741 | +#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) | |
| 29735 | 29742 | if( fstatfs(fd, &fsInfo) == -1 ){ |
| 29736 | 29743 | ((unixFile*)pFile)->lastErrno = errno; |
| 29737 | 29744 | robust_close(p, fd, __LINE__); |
| 29738 | 29745 | return SQLITE_IOERR_ACCESS; |
| 29739 | 29746 | } |
| @@ -29747,11 +29754,11 @@ | ||
| 29747 | 29754 | if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY; |
| 29748 | 29755 | if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK; |
| 29749 | 29756 | if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC; |
| 29750 | 29757 | if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI; |
| 29751 | 29758 | |
| 29752 | -#if SQLITE_ENABLE_LOCKING_STYLE | |
| 29759 | +#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) | |
| 29753 | 29760 | #if SQLITE_PREFER_PROXY_LOCKING |
| 29754 | 29761 | isAutoProxy = 1; |
| 29755 | 29762 | #endif |
| 29756 | 29763 | if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){ |
| 29757 | 29764 | char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING"); |
| 29758 | 29765 |
| --- 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 |