2009/7/29 Peter Miller <[email protected]>: > Ho coders, > > Today's quiz is related to ENOMEDIUM. > > Quite apart from the fact that huge numbers of English speakers are not > even aware the "media" is a plural, let alone that "medium" is its > singular, the strerror for this one ("No medium") is so terse as to be > almost completely free of content. > > So when open(2) returns ENOMEDIUM it would be nice if libexplain could > expand a little on this, based on the type of drive it is. > E.g.: > > ... because there is no disk in the floppy drive > ... because there is no disc in the CD-ROM drive > ... because there is no tape in the tape drive > ... because there is no memory stick in the card reader
I can't remember, are you wrapping the open() call, or just looking at the results? If the former, just printing the device name will give a good clue. If the latter there's not much to go on. If you really care (which seems like overservicing) you could either make guesses based on the device name or perhaps go through /proc/devices to work out what driver corresponds to it and match on that. In some cases there will be a message in dmseg; cdrom drivers seem to be quite chatty about errors. In general I think reading from that will often give good clues and you could automate it a bit, though at the cost of using a file handle and some io. Also that must be the first time I've heard someone mention a floppy disk in a technical thread for years. "no platter in /dev/sda... oh bugger..." :) -- Martin <http://launchpad.net/~mbp/> _______________________________________________ coders mailing list [email protected] http://lists.slug.org.au/listinfo/coders
