|
|
@ -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 @@ EXT4_BCACHE_STATIC_INSTANCE(__cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024); |
|
|
|
/******************************************************************************/ |
|
|
|
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 @@ static int filedev_open(struct ext4_blockdev *bdev) |
|
|
|
/*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_open(struct ext4_blockdev *bdev) |
|
|
|
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 void drop_cache(void) |
|
|
|
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)) |
|
|
|