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

Martin Scholl ms@REDACTED
Tue Nov 4 14:18:02 CET 2008


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]).
** exception error: no match of right hand side value {error,eisdir}
3> {ok, File} = file:open("/dev/sdb", [raw,binary,read]).
** exception error: no match of right hand side value {error,eisdir}
4> {ok, File} = file:open("/dev/sdb", [raw,binary,write]).
** exception error: no match of right hand side value {error,eisdir}
5> {ok, File} = file:open("/dev/sdb", [raw,binary,append]).
** exception error: no match of right hand side value {error,eisdir}
6> {ok, File} = file:open("/dev/sdb", [raw,binary,append,read]).
** exception error: no match of right hand side value {error,eisdir}
7> {ok, File} = file:open("/dev/sdb", [raw,binary,append,write]).
** exception error: no match of right hand side value {error,eisdir}


Are you doing something different than what I have already tried?

After a quick look at unix_efile.c:673 it seems impossible for me to  
open device files other than /dev/null "the standard way".


Martin

P.S.: I will not use those webmailers again.




More information about the erlang-questions mailing list