From a7b8ae9e27fbf58b160baf840158669f1e898bed Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 13 Apr 2011 06:54:56 +0000 Subject: [PATCH] fixed BSD file allocation issue --- ChangeLog | 1 + src/file.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80be059c3..df1f78aaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -85,6 +85,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fixed BSD file allocation issue * fixed bug in session::delete_files option to remove_torrent 0.15.6 release diff --git a/src/file.cpp b/src/file.cpp index 629e11751..8babc44b6 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1579,8 +1579,18 @@ namespace libtorrent fstore_t f = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, s, 0}; if (fcntl(m_fd, F_PREALLOCATE, &f) < 0) { - ec.assign(errno, get_posix_category()); - return false; + if (errno != ENOSPC) + { + ec.assign(errno, get_posix_category()); + return false; + } + // ok, let's try to allocate non contiguous space then + fstore_t f = {F_ALLOCATEALL, F_PEOFPOSMODE, 0, s, 0}; + if (fcntl(m_fd, F_PREALLOCATE, &f) < 0) + { + ec.assign(errno, get_posix_category()); + return false; + } } #endif // F_PREALLOCATE