diff options
author | drh <drh@noemail.net> | 2012-11-13 10:54:12 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-11-13 10:54:12 +0000 |
commit | 0fbb50ee153e654b24c44612056442b377b4763a (patch) | |
tree | 42fbc4d98cbbf437e45a73908992314affe119a4 /src/os_unix.c | |
parent | b43081675d225ef7c5dfbab3adfbeb6c9b509ed2 (diff) | |
download | sqlite-0fbb50ee153e654b24c44612056442b377b4763a.tar.gz sqlite-0fbb50ee153e654b24c44612056442b377b4763a.zip |
When available, use posix_fallocate() rather than ftruncate() to allocate
space for mmap()ed -shm files, since posix_fallocate() gives an error if
no disk space is available whereas ftruncate() is silent and leaves the system
vulnerable to a SIGBUS upon first write to the mmap()ed region.
Ticket [5eaa61ea1881040b17449ca043b6f8fd9ca55dc3]
FossilOrigin-Name: 356259617cfad04492a02912fdf781f54a2b4494
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index ca6213943..21ec0fda9 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4168,11 +4168,19 @@ static int unixShmMap( ** the requested memory region. */ if( !bExtend ) goto shmpage_out; +#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE + if( osFallocate(pShmNode->h, sStat.st_size, nByte)!=0 ){ + rc = unixLogError(SQLITE_IOERR_SHMSIZE, "fallocate", + pShmNode->zFilename); + goto shmpage_out; + } +#else if( robust_ftruncate(pShmNode->h, nByte) ){ rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate", pShmNode->zFilename); goto shmpage_out; } +#endif } } |