aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-04-25 18:01:27 +0000
committerdrh <drh@noemail.net>2011-04-25 18:01:27 +0000
commit9a3baf10ca3bd1f8069c95832c07c0aafe0066d7 (patch)
tree3c4edc7201f82194b74be30fbfa8f3b21803f821 /src/os_unix.c
parent713de341a7ab05201e7d9294354981314ad3f863 (diff)
downloadsqlite-9a3baf10ca3bd1f8069c95832c07c0aafe0066d7.tar.gz
sqlite-9a3baf10ca3bd1f8069c95832c07c0aafe0066d7.zip
Invoke the unix open() system call through a wrapper to avoid problems
resulting from differing declarations to that function in various systems. FossilOrigin-Name: 4c7ff4dd352276e9c01cc536e188cbcd69396952
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 2d3a61637..a760e2c14 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -282,6 +282,18 @@ struct unixFile {
#endif
/*
+** Different Unix systems declare open() in different ways. Same use
+** open(const char*,int,mode_t). Others use open(const char*,int,...).
+** The difference is important when using a pointer to the function.
+**
+** The safest way to deal with the problem is to always use this wrapper
+** which always has the same well-defined interface.
+*/
+static int posixOpen(const char *zFile, int flags, int mode){
+ return open(zFile, flags, mode);
+}
+
+/*
** Many system calls are accessed through pointer-to-functions so that
** they may be overridden at runtime to facilitate fault injection during
** testing and sandboxing. The following array holds the names and pointers
@@ -292,8 +304,8 @@ static struct unix_syscall {
sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
sqlite3_syscall_ptr pDefault; /* Default value */
} aSyscall[] = {
- { "open", (sqlite3_syscall_ptr)open, 0 },
-#define osOpen ((int(*)(const char*,int,...))aSyscall[0].pCurrent)
+ { "open", (sqlite3_syscall_ptr)posixOpen, 0 },
+#define osOpen ((int(*)(const char*,int,int))aSyscall[0].pCurrent)
{ "close", (sqlite3_syscall_ptr)close, 0 },
#define osClose ((int(*)(int))aSyscall[1].pCurrent)