fixed FIEMAP support on linux

This commit is contained in:
Arvid Norberg 2010-04-11 00:48:48 +00:00
parent 6975f4b350
commit 6851254fdf
3 changed files with 21 additions and 4 deletions

View File

@ -26,6 +26,7 @@
incoming connection
* added more detailed instrumentation of the disk I/O thread
* fixed FIEMAP support on linux
* fixed strict aliasing warning on gcc
* fixed inconsistency when creating torrents with symlinks
* properly detect windows version to initialize half-open connection limit

View File

@ -41,12 +41,27 @@ using namespace libtorrent;
int main(int argc, char const* argv[])
{
if (argc != 3)
if (argc != 3 && argc != 2)
{
fprintf(stderr, "Usage: fragmentation_test torrent-file file-storage-path\n");
fprintf(stderr, "Usage: fragmentation_test torrent-file file-storage-path\n"
" fragmentation_test file\n\n");
return 1;
}
if (argc == 2)
{
error_code ec;
file f(argv[1], file::read_only, ec);
if (ec)
{
fprintf(stderr, "Error opening file %s: %s\n", argv[1], ec.message().c_str());
return 1;
}
size_type off = f.phys_offset(0);
printf("physical offset of file %s: %" PRId64 "\n", argv[1], off);
return 0;
}
error_code ec;
boost::intrusive_ptr<torrent_info> ti(new torrent_info(argv[1], ec));

View File

@ -73,7 +73,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sys/ioctl.h>
#ifdef HAVE_LINUX_FIEMAP_H
#include <linux/fiemap.h>
#include <linux/fiemap.h> // FIEMAP_*
#include <linux/fs.h> // FS_IOC_FIEMAP
#endif
#include <asm/unistd.h> // For __NR_fallocate
@ -1394,7 +1395,7 @@ namespace libtorrent
size_type file::phys_offset(size_type offset)
{
#ifdef FS_IOC_FIEMAP
#ifdef FIEMAP_EXTENT_UNKNOWN
// for documentation of this feature
// http://lwn.net/Articles/297696/
struct