nmeum / android-tools

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

Add support for more f2fs-tools executables #127

Closed salvogiangri closed 9 months ago

salvogiangri commented 10 months ago

It would be great if support for building the other executables in f2fs-tools could be added, some missing executables are required by the mkf2fsuserimg.sh script to work, such as sload_f2fs.

Biswa96 commented 9 months ago

Would not it be possible to use the sload.f2fs executable from Linux distribution? For example, ArchLinux has that sload.f2fs executable in f2fs-tools package.

salvogiangri commented 9 months ago

Do those also have specific Android code included (https://android.googlesource.com/platform/external/f2fs-tools/+/refs/heads/main/Android.bp#49)? erofs-utils didn't so I had to use a community fork (https://github.com/sekaiacg/erofs-utils)

salvogiangri commented 9 months ago

I confirm f2fs-tools package does not have Android specific code, when trying to run sload_f2fs with sparse flag the following error occurs:

Error: Sparse mode is only supported for android

https://android.googlesource.com/platform/external/f2fs-tools/+/f5d5adbf61e822a1231117198e0b158f00088b25/lib/libf2fs_io.c#689

Biswa96 commented 9 months ago

I have tried to build sload_f2fs program but it shows segfault.

$ ~/install/bin/sload_f2fs
Error: Device not specified

Wrong program.
Error: Device not specified

Wrong program.
Segmentation fault (core dumped)

Certainly, I am missing something basic. I shall look into it.

Biswa96 commented 9 months ago

Certainly, I am missing something basic.

I forgot to define the macros from libf2fs.

Do you need sload_f2fs only or other tools also?

salvogiangri commented 9 months ago

AOSP build system (which is what I'm trying to use rn) only uses make_f2fs (which is already set up here) and sload_f2fs. The other tools I see in Android.bp are make_f2fs_casefold and fsck.f2fs (which includes resize.f2fs, defrag.f2fs, dump.f2fs). I don't seem to need those at the moment but it would be great to have those as well just in case.

Biswa96 commented 9 months ago

The other tools may conflict with distro provided files. If those tools are renamed then the scripts will fail to find. I'll stick with sload_f2fs only.

Biswa96 commented 9 months ago

I have created pull request to add the sload_f2fs executable. Would you like to test the change please?

salvogiangri commented 9 months ago

Thank you for your time! Will test as soon as possible.

Biswa96 commented 9 months ago

As you are working with f2fs tools, may I ask if you know some basic tests which can be done in CI with this f2fs tools?

salvogiangri commented 9 months ago

I'm currently using those to build flashable OS images in a project of mine (https://github.com/BlackMesa123/UN1CA/blob/4a49c4c7be7cd9b2dbb7ed1f65b0ac686f5ee24d/scripts/build_fs_image.sh#L106-L116). What mkf2fsuserimg.sh does is as simple as:

The only thing I can think of atm is creating a dummy F2FS FS and verify that the image is correctly created as expected