From owner-freebsd-current Sun Feb 11 5:22:31 2001 Delivered-To: freebsd-current@freebsd.org Received: from ns.sanda.gr.jp (ns.sanda.gr.jp [210.232.122.18]) by hub.freebsd.org (Postfix) with ESMTP id E82FC37B401; Sun, 11 Feb 2001 05:22:27 -0800 (PST) Received: from ever.sanda.gr.jp (epoch [10.93.63.51]) by ns.sanda.gr.jp (8.9.3/3.7W) with ESMTP id WAA65293; Sun, 11 Feb 2001 22:22:26 +0900 (JST) From: non@ever.sanda.gr.jp Received: from localhost (localhost [127.0.0.1]) by ever.sanda.gr.jp (8.8.8/3.3W9) with ESMTP id WAA06193; Sun, 11 Feb 2001 22:22:26 +0900 (JST) To: current@FreeBSD.ORG Cc: trevor@jpj.net, akiyama@FreeBSD.ORG Subject: Re: od driver for -CURRENT In-Reply-To: References: <200102101550.f1AFoqO04003@aslan.scsiguy.com> X-Mailer: Mew version 1.94 on Emacs 19.28 / Mule 2.3 =?iso-2022-jp?B?KBskQkt2RSYyVhsoQik=?= Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010211222225N.non@ever.sanda.gr.jp> Date: Sun, 11 Feb 2001 22:22:25 +0900 X-Dispatcher: imput version 20000228(IM140) Lines: 28 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG From: Bruce Evans 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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message