improved fallocate support

This commit is contained in:
Arvid Norberg 2010-01-18 00:51:40 +00:00
parent 8c60c75547
commit 55aea5b863
2 changed files with 17 additions and 0 deletions

View File

@ -93,6 +93,7 @@
* only keeps one outstanding duplicate request per peer
reduces waste download, specifically when streaming
* added support for storing per-peer rate limits across reconnects
* improved fallocate support
* disabled feature to drop requests after having been skipped too many times
* fixed range request bug for files larger than 2 GB in web seeds

View File

@ -76,6 +76,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include <linux/fiemap.h>
#endif
#include <linux/falloc.h>
#include <asm/unistd_64.h> // For __NR_fallocate
// circumvent the lack of support in glibc
static int fallocate(int fd, int mode, loff_t offset, loff_t len)
{
return syscall(__NR_fallocate, fd, mode, offset, len);
}
#elif defined __APPLE__ && defined __MACH__
// mac specifics
@ -1439,6 +1448,13 @@ namespace libtorrent
ec.assign(errno, get_posix_category());
return false;
}
#elif defined TORRENT_LINUX
int ret = fallocate(m_fd, FALLOC_FL_KEEP_SIZE, 0, s);
if (ret != 0 && ret != EOPNOTSUPP && errno != ENOSYS)
{
ec.assign(ret, get_posix_category());
return false;
}
#elif TORRENT_HAS_FALLOCATE
int ret = posix_fallocate(m_fd, 0, s);
if (ret != 0)