/ Check-in [ce2c3e7a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the usage of posix_fallocate() so that it correctly responds to EINVAL returns.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ce2c3e7a875ede4366c48660ae8239d2b74e5f690ad5059844a45f1164f41e61
User & Date: drh 2018-06-02 19:01:54
Context
2018-06-02
19:14
Avoid using a misaligned pointer. check-in: 1ecb3aa1 user: drh tags: trunk
19:01
Fix the usage of posix_fallocate() so that it correctly responds to EINVAL returns. check-in: ce2c3e7a user: drh tags: trunk
17:00
Update a test case in malloc5.test to take into account that malloc() sometimes returns slightly more space than requested. check-in: 3d5eae1c user: dan tags: trunk
14:37
Proposed fix for the use of posix_fallocate() so that it handles EINVAL returns correctly. Closed-Leaf check-in: ab3a5539 user: drh tags: einval-from-fallocate
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  3775   3775         /* The code below is handling the return value of osFallocate() 
  3776   3776         ** correctly. posix_fallocate() is defined to "returns zero on success, 
  3777   3777         ** or an error number on  failure". See the manpage for details. */
  3778   3778         int err;
  3779   3779         do{
  3780   3780           err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);
  3781   3781         }while( err==EINTR );
  3782         -      if( err ) return SQLITE_IOERR_WRITE;
         3782  +      if( err && err!=EINVAL ) return SQLITE_IOERR_WRITE;
  3783   3783   #else
  3784   3784         /* If the OS does not have posix_fallocate(), fake it. Write a 
  3785   3785         ** single byte to the last byte in each block that falls entirely
  3786   3786         ** within the extended region. Then, if required, a single byte
  3787   3787         ** at offset (nSize-1), to set the size of the file correctly.
  3788   3788         ** This is a similar technique to that used by glibc on systems
  3789   3789         ** that do not have a real fallocate() call.