diff --git a/src/file.cpp b/src/file.cpp index c3e89007d..53c30e32a 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include @@ -184,6 +185,17 @@ namespace libtorrent m_fd = ::open(path.external_file_string().c_str() , mode & (rw_mask | no_buffer), permissions); +#ifdef TORRENT_LINUX + // workaround for linux bug + // https://bugs.launchpad.net/ubuntu/+source/linux/+bug/269946 + if (m_fd == -1 && (mode & no_buffer) && errno == EINVAL) + { + mode &= ~no_buffer; + m_fd = ::open(path.external_file_string().c_str() + , mode & (rw_mask | no_buffer), permissions); + } + +#endif if (m_fd == -1) { ec = error_code(errno, get_posix_category()); diff --git a/src/storage.cpp b/src/storage.cpp index b23d22ef7..211c5e66a 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -1203,7 +1203,7 @@ ret: ec = error_code(EIO, get_posix_category()); #endif set_error(m_save_path / file_iter->path, ec); - return -1; + return bytes_transferred; } advance_bufs(current_buf, bytes_transferred); TORRENT_ASSERT(count_bufs(current_buf, bytes_left - file_bytes_left) <= num_bufs);