How to open device as a IO Handle

Lei Pan ln at deakin.edu.au
Wed Jun 8 21:47:04 EDT 2005


Hi, there,

Could anyone tell me how to open a block device (e.g., /dev/hda1) into a 
IO Handle by using GHC (version > 5.0)? I want to open a block/char 
device and return a handle. Apparently, openFile function can't do the 
job. It will be very appreciated if someone could give me a hint.

An earlier post pointed out the problem, but got no reply.
http://www.haskell.org/pipermail/glasgow-haskell-users/2001-November/002624.html

Something I played in GHCI-6.2.2

*Main> openFile "/dev/hdb2" ReadMode >>= \hin -> hGetPosn hin >>= \pos -> print pos

*** Exception: /dev/hdb2: openFile: unsupported operation (unknown file type)

(I already set /dev/hdb2 globally read/write)

Cheers,
Lei


More information about the Glasgow-haskell-users mailing list