aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2017-07-21 21:06:24 +0000
committerdan <dan@noemail.net>2017-07-21 21:06:24 +0000
commit9d70954094ca1fc0c6da29fa92a8d1bd5e87c150 (patch)
tree18629558461a5e2a75c875331002e820e5878140 /src/os_unix.c
parent172861be763dc2fa472de5e814ff16c5e52d22c3 (diff)
downloadsqlite-9d70954094ca1fc0c6da29fa92a8d1bd5e87c150.tar.gz
sqlite-9d70954094ca1fc0c6da29fa92a8d1bd5e87c150.zip
Use ioctl(F2FS_IOC_GET_FEATURES) to determine whether or not atomic batch
writes are available. FossilOrigin-Name: 532bbf1f2b1028db4e581c756533aa660e482d833caaed4eafb299ef9b584f3a
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 3397b3a21..460b0a9bd 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -332,6 +332,9 @@ static pid_t randomnessPid = 0;
#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
+#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, u32)
+
+#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
/*
@@ -507,7 +510,7 @@ static struct unix_syscall {
#define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)
{ "ioctl", (sqlite3_syscall_ptr)ioctl, 0 },
-#define osIoctl ((int(*)(int,int))aSyscall[28].pCurrent)
+#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)
}; /* End of the overrideable system calls */
@@ -3894,12 +3897,12 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
static void setDeviceCharacteristics(unixFile *pFd){
if( pFd->sectorSize==0 ){
int res;
+ u32 f = 0;
assert( pFd->deviceCharacteristics==0 );
/* Check for support for F2FS atomic batch writes. */
- res = osIoctl(pFd->h, F2FS_IOC_START_VOLATILE_WRITE);
- if( res==SQLITE_OK ){
- osIoctl(pFd->h, F2FS_IOC_ABORT_VOLATILE_WRITE);
+ res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f);
+ if( res==0 && (f & F2FS_FEATURE_ATOMIC_WRITE) ){
pFd->deviceCharacteristics =
SQLITE_IOCAP_BATCH_ATOMIC |
SQLITE_IOCAP_ATOMIC |