From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 1 18:41:32 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B262416A41F for ; Mon, 1 Aug 2005 18:41:32 +0000 (GMT) (envelope-from victor.cruceru@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 192D843D46 for ; Mon, 1 Aug 2005 18:41:31 +0000 (GMT) (envelope-from victor.cruceru@gmail.com) Received: by wproxy.gmail.com with SMTP id i1so1090435wra for ; Mon, 01 Aug 2005 11:41:31 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=aKjbfLMQNZ+aiw1IYXoqbqu5TcrRkwkzj0zW+au8fcifqFOk/nfn+4XzdC+4IdtKsh5FF0JA9j6sDHAzQ0JgFEZGO0GP4wJMVG+pp8YaIlaVI/YhA0GZjEY0kqe4hp1vnAotudGG4/ucTyY7OI9un3ouaht+t2jamoeMfxqM/78= Received: by 10.54.83.5 with SMTP id g5mr3131288wrb; Mon, 01 Aug 2005 11:41:30 -0700 (PDT) Received: by 10.54.91.20 with HTTP; Mon, 1 Aug 2005 11:41:30 -0700 (PDT) Message-ID: <4940255050801114161c1cea3@mail.gmail.com> Date: Mon, 1 Aug 2005 21:41:30 +0300 From: victor cruceru To: ticso@cicely.de In-Reply-To: <20050801173047.GC26656@cicely12.cicely.de> Mime-Version: 1.0 References: <494025505080104427c3f91f6@mail.gmail.com> <20050801130502.GA39470@stack.nl> <494025505080106336a329bb@mail.gmail.com> <20050801173047.GC26656@cicely12.cicely.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Marc Olzheim , freebsd-hackers@freebsd.org Subject: Re: O_NONBLOCK for devices with removable media X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: soc-victor@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2005 18:41:32 -0000 Well, if you are doing this from a daemon (multiplexing a lot of events)=20 which is blocked in this open syscall, even 1 second is not reasonable. In= =20 my case it is something more than 30 of seconds (again, on a 5.4 box). I'll= =20 give it a try on FreeBSD 6. I'm currently investigating if there is=20 something like TEST_UNIT_READY (for both ATAPI and SCSI) which can be issue= d=20 on a control device (i.e. /dev/ata) BR,=20 Victor Cruceru On 8/1/05, Bernd Walter wrote: >=20 > On Mon, Aug 01, 2005 at 04:33:23PM +0300, victor cruceru wrote: > > Hi Marc, > > Thanks for the info. Here it is one my situation. I have a CF reader=20 > (fully > > detected by the USB subsystem) with two slots > > (one with a media and one without any media). An open with O_NONBLOCK o= n=20 > the > > empty slot (/dev/da1) is blocking me. >=20 > It should not block for a long time since the device should directly > reply with either ready or no media. >=20 > > Is this OK? >=20 > No, but it is a broken device if you don't get back in a resonable > time. > I don't think that O_NONBLOCK is ment to never block for a short time. > In case of disks you have to ask the device for ready state, if you > don't allow blocking you can't do that and therefor never successfull > open a disk. > The intention should read more in the sense of, don't wait for a disk > to spin up, but even this is problematic to implement correct with many > devices. >=20 > > On 8/1/05, Marc Olzheim wrote: > > > > > > On Mon, Aug 01, 2005 at 02:42:21PM +0300, victor cruceru wrote: > > > > Hi all, > > > > I'm just wondering if it's OK for an open syscall on such a device = ( > i.e. > > > > /dev/acd0 or /dev/da1 with a CF reader attached) to block till the= =20 > media > > > is > > > > ready or a timeout occurs. > > > > > > I'd say that depends completely on whether you supply O_NONBLOCK or= =20 > not, > > > so yes. > > > > > > Quoted from a sound driver discussion at: > > > http://sourceforge.net/mailarchive/message.php?msg_id=3D10011826 > > > > > > > > > On block devices, O_NONBLOCK also is a way to say "don't try to do an= y > > > device discovery", ie you can do a O_NONBLOCK open on a removable dis= k > > > that doesn"t even have any media in it. Again, this has _nothing_ to= =20 > do > > > with whether the device is "busy" or not. > > > > > > ... > > > > > > Short summary: > > > > > > - O_NONBLOCK should generally be seen as just setting the O_NONBLOCK= =20 > flag > > > "early" (ie it"s conceptually equivalent to doing a "F_SETFL" fcntl > > > before the open. It _may_ affect the open itself, but when it does, i= t > > > is generally considered to mean that you can open something that isn'= t > > > even _reachable_. > > > > > > - POSIX doesn't say anything much about its behaviour, except for=20 > named > > > pipes, where it says the total reverse of what ALSA does. But that > > > doesn't actually mean anything, because even that is very much define= d > > > as a special case by POSIX. >=20 > -- > B.Walter BWCT http://www.bwct.de > bernd@bwct.de info@bwct.de >=20 >