How to open device as a IO Handle

Lei Pan ln at
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.

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)


More information about the Glasgow-haskell-users mailing list