From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id D7E66BCAB for ; Wed, 25 May 2005 08:06:42 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j4P66gLp000394 for ; Wed, 25 May 2005 08:06:42 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA20983 for ; Wed, 25 May 2005 08:06:42 +0200 (MET DST) Received: from pd3mo2so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j4P66eha000390 for ; Wed, 25 May 2005 08:06:41 +0200 Received: from pd5mr8so.prod.shaw.ca (pd5mr8so-qfe3.prod.shaw.ca [10.0.141.184]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IH1003T57MGEU50@l-daemon> for caml-list@inria.fr; Wed, 25 May 2005 00:06:16 -0600 (MDT) Received: from pn2ml1so.prod.shaw.ca ([10.0.121.145]) by pd5mr8so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IH10038O7MD6420@pd5mr8so.prod.shaw.ca> for caml-list@inria.fr; Wed, 25 May 2005 00:06:13 -0600 (MDT) Received: from glek.net (S0106000795bd85bd.gv.shawcable.net [24.68.44.127]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0IH100J1J7MC58@l-daemon> for caml-list@inria.fr; Wed, 25 May 2005 00:06:13 -0600 (MDT) Received: from [10.1.0.2] (vpn_client [10.1.0.2]) by glek.net (Postfix) with ESMTP id A2C7745EB28; Tue, 24 May 2005 23:06:12 -0700 (PDT) Date: Tue, 24 May 2005 23:06:12 -0700 From: Taras Subject: partition tables and ocaml In-reply-to: <20050411153551.GA10362@pegasos> To: Sven Luther Cc: caml-list@inria.fr Message-id: <429415D4.4090601@shaw.ca> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en References: <20050411074619.GA26797@pegasos> <20050411125705.GB14415@localhost> <20050411153551.GA10362@pegasos> User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) X-Miltered: at nez-perce with ID 429415F2.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 429415F1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 sven:01 luther:01 sven:01 luther:01 ocaml:01 byte:01 byte:01 plateform:01 bytecode:01 encapsulated:01 bigarray:01 lazy:01 computed:01 partitions:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Sven Luther wrote: >On Mon, Apr 11, 2005 at 08:57:05AM -0400, Eric Cooper wrote: > > >>On Mon, Apr 11, 2005 at 09:46:19AM +0200, Sven Luther wrote: >> >> >>>I had plans to do a rewrite of GNU parted, a project which i am >>>involved with, in ocaml, and am being blocked by a few issues. >>>[...] >>> 1) most disk partition tables and filesystem have a mapping from a >>> given disk 512 byte sector to a descriptive structure. >>> [...] >>> or to have access functions which transform parts of >>> a byte array into values. The first one is ugly, as i was aiming >>> for a purely ocaml solution (so i can build and arch/plateform >>> independent bytecode tool), and the second would probably be a >>> disaster speed wise, and also somewhat ugly unless properly >>> encapsulated in an abstract module. >>> >>> >>I would use the second approach. I would define a logically >>equivalent OCaml record or class, and conversion functions between >>that object and a string + offset (or Bigarray of bytes, plus >>offset). Passing around an offset into a larger byte array can save a >>lot of copying. >> >>You can probably structure your code so that you only convert to/from >>bytes in a few places, not likely to be performance-critical. >> >> > >Mmm, one could imagine a generic set of access function inside a byte array >(would have to handle endianess and such though), and then a structure defined >as a set of lazy values corresponding to the access functions in question, so >only values actually accessed get computed. > >That said, > > Hello, Is a port of Parted to OCaml still in the works? In case you are still wondering, I would like to show out that OCaml can indeed deal with partitions in a painless manner. See http://glek.net/subversion/os/kernel/modules/PartitionTable.ml The read_tables function is capable of doing primary and extended partition table parsing in next to no code. Obviously Parted would need a bit more code than that, but things wouldn't get much hairier since partition entries are only 16 bytes and that code parses 6 of them :) Cheers, Taras