ref: 614f11dab4983bf4e750cd14a4c90437e352bcf5
parent: bc9718e5e24ce9416d6315c9f708181df1a0f5b0
author: gkostka <kostka.grzegorz@gmail.com>
date: Fri Jan 17 13:03:38 EST 2014
Support for large files and block devices.
--- a/blockdev/filedev/ext4_filedev.c
+++ b/blockdev/filedev/ext4_filedev.c
@@ -71,7 +71,7 @@
/******************************************************************************/
static int filedev_open(struct ext4_blockdev *bdev)
{
- dev_file = fopen(fname, "r+b");
+ dev_file = fopen64(fname, "r+b");
if(!dev_file)
return EIO;
@@ -79,7 +79,7 @@
/*No buffering at file.*/
setbuf(dev_file, 0);
- if(fseek(dev_file, 0, SEEK_END))
+ if(fseeko64(dev_file, 0, SEEK_END))
return EFAULT;
_filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize;
@@ -92,7 +92,7 @@
static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
uint32_t blk_cnt)
{
- if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
+ if(fseeko64(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
return EIO;
if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))
@@ -118,7 +118,7 @@
static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt)
{
- if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
+ if(fseeko64(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
return EIO;
if(!fwrite(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))