[erlang-questions] file:read_file_info giving wrong size on a MIPS32 CPU
Sun Feb 12 18:11:05 CET 2017
Petr Gotthard writes:
> we built Erlang for a MIPS32 CPU. Everything looks OK, however file:read_file_info returns incorrect file sizes.
> Where linux stat returns size of 6522 (0x197A), the file:read_file_info returns size of 28011776711034 (0x197A0000197A). The upper 4 bytes should be 0, however they are equal to the lower 4 bytes.
> Did anyone ever experienced something like this? It is a 32b CPU with SIZEOF_OFF_T=8.
Please try the patch below, and show us the console output when you do that read_file_info call.
It could be the kernel putting the wrong data in the high word, your libc getting it wrong,
or even a compiler bug.
If the output shows st_size containing the wrong data in the high word, then the next step
would be to write standalone C program with the stat() call, and run that under strace.
--- otp_src_19.2/erts/emulator/drivers/unix/unix_efile.c.~1~ 2016-12-12 21:15:50.000000000 +0100
+++ otp_src_19.2/erts/emulator/drivers/unix/unix_efile.c 2017-02-12 18:01:26.889209120 +0100
@@ -512,6 +512,10 @@ efile_fileinfo(Efile_error* errInfo, Efi
pInfo->size_low = (Uint32)statbuf.st_size;
+ fprintf(stderr, "st_size 0x%016llx (0x%08x, 0x%08x)\r\n",
+ (unsigned long long) statbuf.st_size,
+ pInfo->size_high, pInfo->size_low);
/* Just look at read/write access for owner. */
More information about the erlang-questions