pengutronix / genimage

tool to generate multiple filesystem and flash images from a tree
GNU General Public License v2.0
305 stars 110 forks source link

Add f2fs support #182

Closed Harvie closed 2 years ago

Harvie commented 2 years ago

Hello, i would like to use f2fs partitions in my images. would that be possible to add please?

Harvie commented 2 years ago

I've been doing some research and f2fs-tools come with tool called sload.f2fs which allows to load files to filesystem image without mounting it. so i guess implementing this would be quite similar to jffs2 for example. but we need to call both mkfs.f2fs and sload.f2fs.

michaelolbrich commented 2 years ago

That sound like it's technically possible. But I probably won't have time for it any time soon. But I would be happy to review a pull request for this.

Harvie commented 2 years ago

Ok, i might take a look at it today. In the meantime, would you be so kind to take a look at my other PR, which is already pending? :-)

Harvie commented 2 years ago

I have some rough code in f2fs branch: https://github.com/Harvie/genimage/tree/f2fs

However when i run it, i get following:

$ ./genimage --config testuj.cfg 
INFO: cmd: "rm -rf "/home/harvie/Temp/genimage/tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/harvie/Temp/genimage/tmp"" (stderr):
INFO: cmd: "cp -a "/home/harvie/Temp/genimage/root" "/home/harvie/Temp/genimage/tmp/root"" (stderr):
INFO: cmd: "mkdir -p "/home/harvie/Temp/genimage/images"" (stderr):
INFO: f2fs(test.f2fs): cmd: "mkfs.f2fs -l 'f2fstest'  -w 512 '/home/harvie/Temp/genimage/images/test.f2fs' 131072" (stderr):
INFO: f2fs(test.f2fs): cmd: "rm -f "/home/harvie/Temp/genimage/images/test.f2fs"" (stderr):
ERROR: f2fs(test.f2fs): failed to generate test.f2fs
INFO: cmd: "rm -rf "/home/harvie/Temp/genimage/tmp"/*" (stderr):

It seems to me that images/test.f2fs file is not created by the time the mkfs.f2fs is run. is not genimage supposed to create that file for me before calling the filesystem module?

Harvie commented 2 years ago

Yes, now i can confirm that images/test.f2fs does not exist by the time mkfs is called. weird.

Harvie commented 2 years ago

Now i see that mkfs.ext2 does create the image file if it does not exist, while mkfs.f2fs does not create it. @michaelolbrich should i just call /bin/fallocate in such case?

Harvie commented 2 years ago

Ok, so i've copied code from image-vfat which solves exactly the same thing.

Harvie commented 2 years ago

@michaelolbrich Ok, this PR seems to be working fine: https://github.com/pengutronix/genimage/pull/185