I use the follow option to mount f2fs(unbntu),and copy some binary files.
mount -o noinline_xattr -o noinline_data test.img ./mnt
then mounted test.img on fuchsia and read one of the binary files.I can read more data(zero) than read the same file on linux.
may be there is a bug here.After use the following code,the fault is not reproduced.
can you help me check the code?
git diff src/storage/f2fs/file.cc
diff --git a/src/storage/f2fs/file.cc b/src/storage/f2fs/file.cc
index 74f6f57c8..b81720c49 100644
--- a/src/storage/f2fs/file.cc
+++ b/src/storage/f2fs/file.cc
@@ -324,6 +324,7 @@ zx_status_t File::Read(void *data, size_t len, size_t off, size_t *out_actual) {
void *data_buf = nullptr;
size_t left = len;
uint64_t npages = (GetSize() + kBlockSize - 1) / kBlockSize;
+ size_t act_left = GetSize() - off; //real left
if (off >= GetSize()) {
*out_actual = 0;
@@ -344,8 +345,10 @@ zx_status_t File::Read(void *data, size_t len, size_t off, size_t *out_actual) {
size_t cur_len = std::min(static_cast<size_t>(kBlockSize - off_in_block), left);
if (n == npages - 1) {
- if (GetSize() % kBlockSize > 0)
+ if (GetSize() % kBlockSize > 0){
cur_len = std::min(cur_len, static_cast<size_t>(GetSize() % kBlockSize));
+ cur_len = std::min(cur_len, act_left);
+ }