From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA04920; Tue, 15 Jan 2002 10:56:15 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA04378 for ; Tue, 15 Jan 2002 10:56:15 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g0F9uCb06723; Tue, 15 Jan 2002 10:56:12 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA04324; Tue, 15 Jan 2002 10:56:12 +0100 (MET) Date: Tue, 15 Jan 2002 10:56:12 +0100 From: Xavier Leroy To: Garry Hodgson Cc: ocaml Subject: Re: [Caml-list] error opening large file Message-ID: <20020115105612.A4497@pauillac.inria.fr> References: <3C3F52ED.2F4B0190@sage.att.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3C3F52ED.2F4B0190@sage.att.com>; from garry@sage.att.com on Fri, Jan 11, 2002 at 04:02:37PM -0500 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > i get the following error when i open a large file (2561435180 bytes): > > let chan = open_in( "com.zone" );; > Uncaught exception: > Sys_error > "com.zone: Value too large for defined data type". > > is there a 2G file size limitation? if so, why? > i found the same bug in erlang, though C is ok with it. Actually, this limitation is in the kernel and C library. To ensure backward compatibility with old programs that assume that the size of a file fits in a 32-bit signed integer, system calls come in two versions and/or with special options, one to select 32-bit file sizes (and fail on files larger than 2G), one to select 64-bit file sizes. The choice between the two versions is done through compile-time defines, and the default can be either 32 or 64 depending on the C library. You could try to recompile the OCaml sources with the -D_FILE_OFFSET_BITS=64 flag. That will let you open the large file, and read it sequentially, but of course file positions and stats (as returned by in_channel_length, seek_in, Unix.stat, etc) will be wrong, since they wrap around at 2^30 on a 32-bit machine. Now that I think I've figured it out, I plan to compile future versions of OCaml in 64-bit-file-size mode, and add new library functions to manipulate file positions and sizes as 64-bit integers (seek_in64, Unix.stat64, etc). - Xavier Leroy ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr