nmeum / android-tools

Unoffical CMake-based build system for android command line utilities
Apache License 2.0
176 stars 51 forks source link

CMake: Add make_f2fs tool for fastboot #125

Closed Biswa96 closed 11 months ago

Biswa96 commented 11 months ago

Fixes https://github.com/nmeum/android-tools/issues/109

make_f2fs tool is reqired by fastboot. If the make_f2fs executable is
not present the following error is shown.

$ fastboot format:f2fs userdata
/usr/bin/make_f2fs failed with status 1
fastboot: error: Cannot generate image for userdata

This commit also splits libext2_uuid static library from libext2fs
JamiKettunen commented 11 months ago

Format with f2fs appears to work at first glance (though with excess output) but when the device reboots it can still mount userdata as ext4 with all data intact

$ fastboot format:f2fs userdata

    F2FS-tools: mkfs.f2fs Ver: 1.16.0 (2023-04-11)

Info: Disable heap-based policy
Info: Debug level = 1
Info: Trim is disabled
Info: Set conf for android
Info: Enable Project quota
Info: not exist /proc/version!
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 103219136 (50399 MB)
Info: zone aligned segment0 blkaddr: 512
Info: add quota type = 0 => 4
Info: add quota type = 1 => 5
Info: add quota type = 2 => 6
Info: format version with
  "6.4.16-0-generic"
[f2fs_init_sit_area: 640]   Filling sit area at offset 0x00600000
[f2fs_init_nat_area: 674]   Filling nat area at offset 0x00a00000
[f2fs_write_root_inode:1292]    Writing root inode (hot node), 14c00 0 200 at offset 0x00084992
[f2fs_write_default_quota:1368]     Writing quota data, at offset 00015201, 00015202
[f2fs_write_qf_inode:1425]  Writing quota inode (hot node), 14c00 0 200 at offset 0x00084993
[f2fs_write_default_quota:1368]     Writing quota data, at offset 00015203, 00015204
[f2fs_write_qf_inode:1425]  Writing quota inode (hot node), 14c00 0 200 at offset 0x00084994
[f2fs_write_default_quota:1368]     Writing quota data, at offset 00015205, 00015206
[f2fs_write_qf_inode:1425]  Writing quota inode (hot node), 14c00 0 200 at offset 0x00084995
[f2fs_update_nat_root:1479]     Writing nat root, at offset 0x00000a00
[f2fs_add_default_dentry_root:1676]     Writing default dentry root, at offset 0x00015200
Info: Overprovision ratio = 0.650%
Info: Overprovision segments = 163 (GC reserved = 160)
[f2fs_write_check_point_pack: 837]  Writing main segments, cp at offset 0x00000200
[f2fs_write_check_point_pack: 993]  Writing Segment summary for HOT/WARM/COLD_DATA, at offset 0x00000201
[f2fs_write_check_point_pack:1020]  Writing Segment summary for HOT_NODE, at offset 0x00000202
[f2fs_write_check_point_pack:1032]  Writing Segment summary for WARM_NODE, at offset 0x00000203
[f2fs_write_check_point_pack:1043]  Writing Segment summary for COLD_NODE, at offset 0x00000204
[f2fs_write_check_point_pack:1051]  Writing cp page2, at offset 0x00000205
[f2fs_write_check_point_pack:1071]  Writing NAT bits pages, at offset 0x000003fe
[f2fs_write_check_point_pack:1092]  Writing cp page 1 of checkpoint pack 2, at offset 0x00000400
[f2fs_write_check_point_pack:1111]  Writing cp page 2 of checkpoint pack 2, at offset 0x00000405
[f2fs_write_super_block:1144]   Writing super block, at offset 0x00000000
Info: format successful
Sending 'userdata' (97 KB)                         OKAY [  0.004s]
Writing 'userdata'                                 OKAY [  0.549s]
Finished. Total time: 0.806s

For reference if I try with ext4 instead it makes a >4M image instead and formats as expected so maybe it just doesn't override; I'll do more testing tomorrow but this is a bit odd, maybe I'll also try official platform tools for reference

Biswa96 commented 11 months ago

Hi, did you compare the expected behavior with official platform tools?

Biswa96 commented 11 months ago

I am merging this because this fixes the error in the issue.

JamiKettunen commented 11 months ago

Sorry for delay, I did try official tools too and they behaved the same (including verbose output)