Issues with System.Posix.Files

David Brown haskell2 at davidb.org
Sun Mar 4 19:43:54 EST 2007


Bjorn Bringert wrote:
> On Mar 4, 2007, at 23:46 , David Brown wrote:
>
>> Hi, I'm writing some code to use System.Posix.Files to restore a
>> filesystem.  I've discovered a few missing things.
>>
>>   - There is a createDevice, but the mode values needed to pass to
>>     this call aren't exported (blockSpecialMode,
>>     characterSpecialMode).
>
> Wouldn't you also need to be able to specify the major and minor
> numbers for the device? I have a first try at that in the
> System.PosixCompat.Extensions module in the unix-compat package
> (darcs repo:
> http://www.cs.chalmers.se/~bringert/darcs/unix-compat/). The
> unix-compat package aims to provide the unix package API on all
> platforms, with suitable dummy implementations when there is no
> corresponding functionality.

Looks good.  It's really curious how Linux has decided to add 16 bit
major and minor numbers into the picture.  They still use the low bit
for minor and the next 8 bits for major.  Then the upper groups of 8
bits are tacked on, all interleaved and such.  Best to just call the
macros :-)

I don't really need these, since I'm just putting devices back to the
way there were.

Also, Your Files.hsc doesn't export blockSpecialMode either.  I think
having that and characterSpecialMode and fileTypeModes exported would
make manipulating those bits a lot nicer.

Dave



More information about the Libraries mailing list