Open Unix.LargeFile to avoid "lstat: Value too large for defined data type".
authorRichard W.M. Jones <rjones@redhat.com>
Mon, 1 Feb 2021 10:07:02 +0000 (10:07 +0000)
committerHilko Bengen <bengen@debian.org>
Mon, 23 Aug 2021 12:26:58 +0000 (13:26 +0100)
On 32 bit platforms, because OCaml native ints are limited to 31 bits,
there is a trap in the normal Unix.stat, Unix.lstat functions where
any field in the stat struct may overflow.  The result is random
errors like:

  supermin: error: lstat: Value too large for defined data type: /tmp/tmp.Ss9aYEBASm/d2/root

You would probably only see this on armv7.

The OCaml Unix module has a "LargeFile" submodule which fixes this by
using int64 for some (unfortunately not all) fields.

For more information see the OCaml sources, file
otherlibs/unix/stat.c, all instances of "EOVERFLOW".

Gbp-Pq: Name 0001-Open-Unix.LargeFile-to-avoid-lstat-Value-too-large-f.patch

src/format_chroot.ml
src/format_ext2.ml
src/format_ext2_initrd.ml
src/format_ext2_kernel.ml
src/mode_build.ml
src/package_handler.ml
src/ph_dpkg.ml
src/ph_pacman.ml
src/ph_rpm.ml
src/supermin.ml
src/utils.ml

index 346c24bfa2573f78fd503798f5e9752f68a1bb21..34606f77543cd85d284ba48c65d809564ec2efe6 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 6348c29727b125f77a817b67db86917b4a09a8e4..e311ea633deb29a0238990b695c342db95682ab3 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 38977e6a92b3c844a7769416bf07a892aed0c535..6268442ee37e222356d3eafb6cb2199c378b60e1 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 98bff3a852022572cd659c000bc7ad9fe53ff720..3be4413bf99383331a36c4afee96834edc644899 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
@@ -95,8 +96,8 @@ and find_kernel_from_lib_modules debug =
     let kernels =
       filter_map (
         fun kernel_file ->
-          let size = try (stat kernel_file).st_size with Unix_error _ -> 0 in
-          if size < 10000 then None
+          let size = try (stat kernel_file).st_size with Unix_error _ -> 0L in
+          if size < 10000_L then None
           else (
             let kernel_name = Filename.basename kernel_file in
             let modpath = Filename.dirname kernel_file in
index ed4736656d4e9cf45296033f82d204a7d872944d..ff7733e4b1fc461e86aa93e6102f49c99d347baf 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 040943847800879a36bb85ad26cf51c87f15243a..f0d6db3f7a50199b2e2c6f3028c36906d9ab5f96 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 1e785de28d2cc35cad41546ec81e7933adfcf9dc..6d4fce1be1f8d9c9096032c9d20953a060fcaad2 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 67f751274a2e5a11128ec0b97b417908ebce023d..50500a5eecd98fe6917e02aacf1fa0d087604f0b 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index 9745efd9cc0db0c07a9a890ba56f27fb983cf199..183b5f3ff8a0789cf371c6354c1644433be38b3b 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Utils
index e92311153f3caf394d13c956e2bdd0a3c41abf53..9f838d94311ae1cac42914922d3f4b61d9da4437 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 open Types
index b25df8898126b7e5030272213769dd9e225a15fa..f5990ef8de8fc695949e12f1de128618206098ed 100644 (file)
@@ -17,6 +17,7 @@
  *)
 
 open Unix
+open Unix.LargeFile
 open Printf
 
 let (+^) = Int64.add