diff options
author | katao <katao@xiaomi.com> | 2018-03-27 13:25:46 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@google.com> | 2018-03-27 10:29:21 -0700 |
commit | 457c9920f0747f476d88a022203a88a16223088a (patch) | |
tree | 86be5855c1cb8d081736d65a595a53566b306b3b /lib | |
parent | 6b39975d136e81cc2f67baf661423f233c271c93 (diff) | |
download | android_external_f2fs-tools-457c9920f0747f476d88a022203a88a16223088a.tar.gz android_external_f2fs-tools-457c9920f0747f476d88a022203a88a16223088a.tar.bz2 android_external_f2fs-tools-457c9920f0747f476d88a022203a88a16223088a.zip |
FROMLIST: libf2fs: reset wanted_total_sectors by new sector_size
(am from https://sourceforge.net/p/linux-f2fs/mailman/message/36277204/)
The args of wanted_total_sectors is calculated based
on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i)
may be reset dev_sector_size, we should reset the number
of wanted_total_sectors.
This bug was reported to Google Issue Tracker.
Link: https://issuetracker.google.com/issues/76407663
Test: userdata use f2fs and enforce encryption.Boot after factory reset.
Change-Id: I8550372f5d8c6ff88f9e242fd591e977107d03ed
Signed-off-by: katao <katao@xiaomi.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libf2fs.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c index ffdbccb..591c97f 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -812,8 +812,15 @@ int get_device_info(int i) #ifdef BLKSSZGET if (ioctl(fd, BLKSSZGET, §or_size) < 0) MSG(0, "\tError: Using the default sector size\n"); - else if (dev->sector_size < sector_size) + else if (dev->sector_size < sector_size){ + /* + * wanted_total_sectors need to be reset by new + * sector_size. + */ + c.wanted_total_sectors = (c.wanted_total_sectors * + dev->sector_size) / sector_size; dev->sector_size = sector_size; + } #endif #ifdef BLKGETSIZE64 if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) { |