summaryrefslogtreecommitdiff
path: root/src/FallocFileAllocationIterator.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-03-25 05:43:07 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-03-25 05:43:07 +0000
commit29c5ef9215be004b31cd53ef8841680c3f015d57 (patch)
treeacae3135c9240d627b30629c5a7594951a4cb688 /src/FallocFileAllocationIterator.h
parentfe614395d60da75836dbfb3f0a593d91b4024a89 (diff)
2009-03-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added 'falloc' parameter for --file-allocation option. 'falloc' allocation mode uses posix_fallocate() system call to allocate file on disk. If you are using newer file systems such as ext4 (with extents support), btrfs or xfs, 'falloc' is your best choice. It allocates large(few GiB) files almost instantly. Don't use 'falloc' with legacy file systems such as ext3 because it takes almost same time as 'prealloc' and it blocks aria2 entirely until allocation finishes. 'falloc' may not be available if your system doesn't have posix_fallocate() system call. * configure.ac * src/AbstractDiskWriter.cc * src/AbstractDiskWriter.h * src/AbstractSingleDiskAdaptor.cc * src/BinaryStream.h * src/BtCheckIntegrityEntry.cc * src/ByteArrayDiskWriter.h * src/CheckIntegrityEntry.cc * src/CheckIntegrityEntry.h * src/DefaultPieceStorage.cc * src/DiskAdaptor.cc * src/DiskAdaptor.h * src/DiskWriter.h * src/FallocFileAllocationIterator.cc * src/FallocFileAllocationIterator.h * src/FileAllocationEntry.cc * src/FileAllocationEntry.h * src/Makefile.am * src/MultiFileAllocationIterator.cc * src/MultiFileAllocationIterator.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/StreamCheckIntegrityEntry.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/FallocFileAllocationIteratorTest.cc * test/Makefile.am
Diffstat (limited to 'src/FallocFileAllocationIterator.h')
-rw-r--r--src/FallocFileAllocationIterator.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/FallocFileAllocationIterator.h b/src/FallocFileAllocationIterator.h
new file mode 100644
index 00000000..6f6cfa65
--- /dev/null
+++ b/src/FallocFileAllocationIterator.h
@@ -0,0 +1,65 @@
+/* <!-- copyright */
+/*
+ * aria2 - The high speed download utility
+ *
+ * Copyright (C) 2009 Tatsuhiro Tsujikawa
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you
+ * do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+ */
+/* copyright --> */
+#ifndef _D_FALLOC_FILE_ALLOCATION_ITERATOR_H_
+#define _D_FALLOC_FILE_ALLOCATION_ITERATOR_H_
+
+#include "FileAllocationIterator.h"
+#include "BinaryStream.h"
+
+namespace aria2 {
+
+// Allocate disk space using posix_fallocate() system call.
+class FallocFileAllocationIterator:public FileAllocationIterator {
+private:
+ BinaryStream* _stream;
+ off_t _offset;
+ uint64_t _totalLength;
+public:
+ FallocFileAllocationIterator(BinaryStream* stream, off_t offset,
+ uint64_t totalLength);
+
+ virtual void allocateChunk();
+
+ virtual bool finished();
+
+ virtual off_t getCurrentLength();
+
+ virtual uint64_t getTotalLength();
+};
+
+} // namespace aria2
+
+#endif // _D_FALLOC_FILE_ALLOCATION_ITERATOR_H_
+