[erlang-questions] file:open/2 and Unix Device Files

Colm Dougan colm.dougan@REDACTED
Tue Nov 4 14:43:54 CET 2008


On Tue, Nov 4, 2008 at 1:18 PM, Martin Scholl <ms@REDACTED> wrote:
> Hello again,
>
> Quoting Colm Dougan <colm.dougan@REDACTED>:
> [snip]
>> I don't have the answer to that.  However, in case you were not aware,
>> if you open a file in "raw" mode then you can read device files.
> Thank you for hinting me this, but I am afraid it doesn't work for me(r):
>
> Erlang (BEAM) emulator version 5.6.4 [source] [64-bit] [smp:2]
> [async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.6.4  (abort with ^G)
> 1> {ok, File} = file:open("/dev/sdb", [raw]).
> ** exception error: no match of right hand side value {error,eisdir}
> 2> {ok, File} = file:open("/dev/sdb", [raw,binary]).

Apologies - I got my wires crossed.  Opening file in raw mode works
for /proc (whereas file:read_file doesn't) but it doesn't work for
/dev.

Colm



More information about the erlang-questions mailing list