Apparently some large-file systems out there, such as my powerpc64le Linux box, define daddr_t as a 32-bit type, which is sad and stymies cross-building disk images. Cast daddr_t to off_t before doing arithmetic that overflows.
Compile and build disk images using cheribuild
What guarantee is there that off_t is going to be better? If we are cross building, wouldn't it be better to ensure we get the right sized data types rather than play whack a mole like this? Daddr_t is a block offset.
|62 ↗||(On Diff #80264)|
Wouldn't it be better to add
#ifdef linux typedef int64_t freebsd_daddr_t #define daddr_t freebsd_daddr_t #endif
towards the top of this file?
It ultimately gets passed to lseek, so if your off_t is 32-bit nothing's going to help you. If we cared about bootstrapping on 32-bit Linux we'd have to enable LFS for lseek to work at which point off_t is then correct again (or explicitly use lseek64 and off64_t).
We _could_ get away with _just_ including the cast part of the diff and still use daddr_t everywhere else if you want a more minimal diff, but you'd still be limited to BLOCKSIZE * 2^32 bytes on such 64-bit Linux systems.
Hm, on reflection, this doesn't quite do what it claims. Many of the arguments to this function come from fsbtodb and there are lots of daddr_t's floating around. Unless you want to purge all of them from existence (which is notionally wrong as they _are_ block numbers) I'd suggest leaving just the cast and dropping the rest of the diff.