Quantcast

file:read_file_info giving wrong size on a MIPS32 CPU

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

file:read_file_info giving wrong size on a MIPS32 CPU

Petr Gotthard
Hello,
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.
 
 
Kind Regards,
Petr
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: file:read_file_info giving wrong size on a MIPS32 CPU

Mikael Pettersson-5
Petr Gotthard writes:
 > Hello,
 > 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
 #endif
     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);
+
 #ifdef NO_ACCESS
     /* Just look at read/write access for owner. */
 
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...