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

Doesn't build on FreeBSD #202

Closed yurivict closed 1 year ago

yurivict commented 1 year ago

... due to use of linux-specific headers:

#include <linux/fs.h> 
#include <linux/fiemap.h>

Please consider porting to BSD.

michaelolbrich commented 1 year ago

So this is used to detect holes. It makes copying images more efficient and is used to create Android sparse images. If you can life without these the easy solution is to just assume there are no holes. We already do that if the runtime detection fails.

yurivict commented 1 year ago

Is there a compile-time option to disable these?

michaelolbrich commented 1 year ago

I think #204 should fix this. Can you try? I don't have any BSD to test this so I can only fake it a bit.

yurivict commented 1 year ago

Thanks for fixing it.

Now it breaks like this:

util.c:475:7: warning: implicit declaration of function 'fallocate' is invalid in C99 [-Wimplicit-function-declaration]
                if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                    ^
util.c:475:21: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
                if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                                  ^
util.c:475:44: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
                if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,

fallocate is Linux-only. Can this be done with posix_fallocate ?

michaelolbrich commented 1 year ago

So posix_fallocate does not have the same semantics. I've created #208 that just skips fallocate and uses the existing fallback path. Can you test this?