diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-06-14 14:12:19 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-06-14 15:59:47 +0200 |
| commit | 2d85c7e86d893946a4f0e84f57698833c3b79c37 (patch) | |
| tree | d771794cac097e13da7aa3966084917076610d54 /src/posix.c | |
| parent | 0c2d0d4b90401088c5c67eea2c4c80588c854ff7 (diff) | |
| download | libgit2-2d85c7e86d893946a4f0e84f57698833c3b79c37.tar.gz | |
posix: remove `p_fallocate` abstraction
By now, we have repeatedly failed to provide a nice
cross-platform implementation of `p_fallocate`. Recent tries to
do that escalated quite fast to a set of different CMake checks,
implementations, fallbacks, etc., which started to look real
awkward to maintain. In fact, `p_fallocate` had only been
introduced in commit 4e3949b73 (tests: test that largefiles can
be read through the tree API, 2019-01-30) to support a test with
large files, but given the maintenance costs it just seems not to
be worht it.
As we have removed the sole user of `p_fallocate` in the previous
commit, let's drop it altogether.
Diffstat (limited to 'src/posix.c')
| -rw-r--r-- | src/posix.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/posix.c b/src/posix.c index 32ca704f1..bffe02e05 100644 --- a/src/posix.c +++ b/src/posix.c @@ -155,44 +155,6 @@ int p_rename(const char *from, const char *to) return -1; } -int p_fallocate(int fd, off_t offset, off_t len) -{ -#if defined (__APPLE__) || (defined (__NetBSD__) && __NetBSD_Version__ < 700000000) - fstore_t prealloc; - struct stat st; - size_t newsize; - int error; - - if ((error = p_fstat(fd, &st)) < 0) - return error; - - if (git__add_sizet_overflow(&newsize, offset, len)) { - errno = EINVAL; - return -1; - } - - if (newsize < (unsigned long long)st.st_size) - return 0; - - memset(&prealloc, 0, sizeof(prealloc)); - prealloc.fst_flags = F_ALLOCATEALL; - prealloc.fst_posmode = F_PEOFPOSMODE; - prealloc.fst_offset = offset; - prealloc.fst_length = len; - - /* - * fcntl will often error when the file already exists; ignore - * this error since ftruncate will also resize the file (although - * likely slower). - */ - fcntl(fd, F_PREALLOCATE, &prealloc); - - return ftruncate(fd, (offset + len)); -#else - return posix_fallocate(fd, offset, len); -#endif -} - #endif /* GIT_WIN32 */ ssize_t p_read(git_file fd, void *buf, size_t cnt) |
