file: module and character special files

Shawn Pearce spearce@REDACTED
Tue Mar 2 15:15:21 CET 2004

Matthias Lang <matthias@REDACTED> wrote:
> (changing the manual to at least say that 'eisdir' doesn't necessarily
> mean it's a directory seems like a universally acceptable solution.)

I agree, this is the best solution right now.  Denote in the manual that
eisdir may be returned even if the item is not a directory, and that
the caller should use the file info function to determine the actual
type of the item which cannot be opened with the file module.

Can we also get a file:open_device or something that goes around
the back of file:open and lets you get a device opened up?  Being a
new call, it wouldn't need to return {error, eisdir}.  :)

Its quite unfortunate that this has happened, but I can't say I blame
them.  It most likely occurred because whoever wrote the code forgot
UNIX offers other file types, and originally just tested for regular
file and directory types, returning {error, eisdir}.  Months later
someone tries to open a device, and it succeeds.  They file a bug
asking that file:open return an error instead.  The developer tries
to return a different error condition, but there's already a ton of code
written as:

	case file:open(Foo) of
	{ok, Fd} ->
	{error, esidir} ->

which would yeild a badmatch in the caller.  With the requirements
for uptime, the developer chose to not cause badmatch.  Ugh!


More information about the erlang-questions mailing list