Efile_drv and non-regular files

Daniel Neri <>
Wed Mar 1 23:27:47 CET 2000


        Hi,

I just happened to try the following, while playing around in the
shell:

,----
| Erlang (BEAM) emulator version 4.9.1 [source]
| 
| Eshell V4.9.1  (abort with ^G)
| 1> {ok, F} = file:open("/dev/null", [read]).
| ** exited: {{badmatch,{error,eisdir}},[{erl_eval,expr,3}]} **
`----

It turns out efile_drv tries to protect the user a wee bit too hard
IMO, by making "open" on *any* non-regular file fail with
"eisdir". Wouldn't it be better to leave the "protection business" to
the underlying OS? Opening a special file might be valid in some
cases.

I propose removing the "regular file" check in efile_openfile (see
patch below), thus allowing for:

,----
| 8> {ok, F} = file:open("/dev/urandom", [read]).
| {ok,<0.38.0>}
| 9> file:read(F, 10).                           
| {ok,[133,127,43,164,72,146,120,246,240,80]}
`----

But still not letting through the obvious error (which I assume was
the reason for this check):

,----
| 10> {ok, T} = file:open("/tmp", [write]).
| ** exited: {{badmatch,{error,eisdir}},[{erl_eval,expr,3}]} **
`----

At the least, use a less misleading error identifier...


Best wishes,
/Daniel

-- 
Daniel Neri




More information about the erlang-questions mailing list