From: Bruce Evans <[EMAIL PROTECTED]>
Date: Sun, 11 Feb 2001 07:35:51 +1100 (EST)
> On Sat, 10 Feb 2001, Justin T. Gibbs wrote:
> > >Are there any reason device drivers do not check if thier devices are
> > >writable or not when they are opened ? I think returning an error
> > >value, like `od', is the easiest way to avoid this problem.
> > 
> > It is not necessarily sufficient since the media may be changed after
> > open on certain types of devices that don't have a media lock.  Some
> > devices will only tell you that they are write protected on the first
> > write, etc.  For the devices where we can tell, we should make the check
> > in open, but not rely on that catching all cases where a driver will
> > return EACCESS.
> 
> Also, writing to a write protected sector is a special case of an i/o
> error, so it will be handled by non-broken general i/o error handling.
> Also^2, write protection might be for individual sectors and might
> change while the device is open, just like most i/o errors.  We actually
> have this for most disks -- FreeBSD has write protection of label
> sectors in software, and it can be turned on and off while the device
> is open.

Though both of them cannot be handled, I think it's worth checking
if the entire device is write-protected or not at open(). Especially
when the implementation is not so difficult. Why you have to try
writing to a write-protected medium ?

// Noriaki Mitsunaga //


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to