#include <ext_common.h>
#include <ext4fs.h>
#include "ext4_common.h"
+#include <div64.h>
int ext4fs_symlinknest;
struct ext_filesystem ext_fs;
if (len > filesize)
len = filesize;
- blockcnt = ((len + pos) + blocksize - 1) / blocksize;
+ blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize);
- for (i = pos / blocksize; i < blockcnt; i++) {
+ for (i = lldiv(pos, blocksize); i < blockcnt; i++) {
lbaint_t blknr;
- int blockoff = pos % blocksize;
+ int blockoff = pos - (blocksize * i);
int blockend = blocksize;
int skipfirst = 0;
blknr = read_allocated_block(&(node->inode), i);
/* Last block. */
if (i == blockcnt - 1) {
- blockend = (len + pos) % blocksize;
+ blockend = (len + pos) - (blocksize * i);
/* The last portion is exactly blocksize. */
if (!blockend)
}
/* First block. */
- if (i == pos / blocksize) {
+ if (i == lldiv(pos, blocksize)) {
skipfirst = blockoff;
blockend -= skipfirst;
}
return ret == 0;
}
-int ext4fs_size(const char *filename)
+int ext4fs_size(const char *filename, loff_t *size)
{
- loff_t size;
- int ret;
-
- ret = ext4fs_open(filename, &size);
- if (ret)
- return ret;
- else
- return size;
+ return ext4fs_open(filename, size);
}
int ext4fs_read(char *buf, loff_t len, loff_t *actread)
return 0;
}
-int ext4_read_file(const char *filename, void *buf, int offset, int len)
+int ext4_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
+ loff_t *len_read)
{
loff_t file_len;
- loff_t len_read;
int ret;
if (offset != 0) {
if (len == 0)
len = file_len;
- ret = ext4fs_read(buf, len, &len_read);
-
- if (ret)
- return ret;
- else
- return len_read;
+ return ext4fs_read(buf, len, len_read);
}
int ext4fs_uuid(char *uuid_str)