shithub: lwext4

Download patch

ref: 8ed88939d52a36b141607bac3d0b9acf5427093e
parent: 614f11dab4983bf4e750cd14a4c90437e352bcf5
author: gkostka <kostka.grzegorz@gmail.com>
date: Fri Jan 17 13:13:02 EST 2014

Support for large files and block devices.

--- a/blockdev/filedev/ext4_filedev.c
+++ b/blockdev/filedev/ext4_filedev.c
@@ -25,6 +25,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
+#define _FILE_OFFSET_BITS 64
+
 #include <ext4_config.h>
 #include <ext4_blockdev.h>
 #include <ext4_errno.h>
@@ -71,7 +74,7 @@
 /******************************************************************************/
 static int filedev_open(struct ext4_blockdev *bdev)
 {
-    dev_file = fopen64(fname, "r+b");
+    dev_file = fopen(fname, "r+b");
 
     if(!dev_file)
         return EIO;
@@ -79,7 +82,7 @@
     /*No buffering at file.*/
     setbuf(dev_file, 0);
 
-    if(fseeko64(dev_file, 0, SEEK_END))
+    if(fseek(dev_file, 0, SEEK_END))
         return EFAULT;
 
     _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize;
@@ -92,7 +95,7 @@
 static int filedev_bread(struct  ext4_blockdev *bdev, void *buf, uint64_t blk_id,
     uint32_t blk_cnt)
 {
-    if(fseeko64(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
+    if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
         return EIO;
 
     if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))
@@ -118,7 +121,7 @@
 static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf,
     uint64_t blk_id, uint32_t blk_cnt)
 {
-    if(fseeko64(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
+    if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
         return EIO;
 
     if(!fwrite(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))