Browse thread
ocaml, int32/64, bigarray and unsigned values ...
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-05-25 (09:15) |
From: | Sven Luther <sven.luther@w...> |
Subject: | Re: partition tables and ocaml |
On Tue, May 24, 2005 at 11:06:12PM -0700, Taras wrote: > 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 Yes, altough i am a bit short on time right now. > 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 Cool, will look at this. Also maybe you would be interested in cooperating on the project ? > 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 :) Yes, but fdisk/mbr like partition tables are trivial, parted supports many kind of partition table, among them the mac/amiga ones which i am most familiar with, and which handle linked lists of partitions. Friendly, Sven Luther