From owner-freebsd-questions@FreeBSD.ORG Wed Feb 10 17:54:01 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E380B106566B for ; Wed, 10 Feb 2010 17:54:01 +0000 (UTC) (envelope-from jmc-freebsd2@milibyte.co.uk) Received: from relay.ptn-ipout02.plus.net (relay.ptn-ipout02.plus.net [212.159.7.36]) by mx1.freebsd.org (Postfix) with ESMTP id 7F6758FC0A for ; Wed, 10 Feb 2010 17:54:01 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAIaBckvUnw4U/2dsb2JhbACaY3S9DIRVBA Received: from pih-relay08.plus.net ([212.159.14.20]) by relay.ptn-ipout02.plus.net with ESMTP; 10 Feb 2010 17:53:59 +0000 Received: from [84.92.153.232] (helo=curlew.milibyte.co.uk) by pih-relay08.plus.net with esmtp (Exim) id 1NfGlD-0001hF-Hn; Wed, 10 Feb 2010 17:53:59 +0000 Received: by curlew.milibyte.co.uk with local (Exim 4.71) (envelope-from ) id 1NfGlD-0001Ih-6j; Wed, 10 Feb 2010 17:53:59 +0000 From: Mike Clarke To: freebsd-questions@freebsd.org Date: Wed, 10 Feb 2010 17:53:59 +0000 User-Agent: KMail/1.9.10 References: <201002061511.11639.jmc-freebsd2@milibyte.co.uk> <201002062328.27744.jmc-freebsd2@milibyte.co.uk> <4B6EA394.5050604@gmx.com> In-Reply-To: <4B6EA394.5050604@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201002101753.59159.jmc-freebsd2@milibyte.co.uk> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: jmc-freebsd2@milibyte.co.uk X-SA-Exim-Scanned: No (on curlew.milibyte.co.uk); SAEximRunCond expanded to false X-Plusnet-Relay: c8f3c6ea7ba53d420ff80c37b184613e Cc: Nikos Vassiliadis Subject: Re: Detecting cards in USB card reader X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2010 17:54:02 -0000 On Sunday 07 February 2010, Nikos Vassiliadis wrote: > While it may feel dangerous, is perfectly safe. There is no > way doing an IO operation on a disk-like device using requests > othen than multiplies of the physical block which currently is > 512 bytes. Opening the disk for writing and trying to do a > write request, will just force GEOM to re-examine the device. > > > lab# echo asd | cat > /dev/da0 > > cat: stdout: Invalid argument > > failed > > > lab# echo > /dev/da0 > > lab# echo $? > > 1 > > failed > > > lab# /bin/echo asd > /dev/da0 > > /bin/echo: write: Invalid argument > > failed > > Closer look: > > lab# truss sh -c "echo > /dev/da0" > > snip > > > open("/dev/da0",O_WRONLY|O_CREAT|O_TRUNC,0666) = 2 (0x2) > > dup2(0x2,0x1,0x1b6,0x1000008,0x2830d040,0x2830235c) = 1 (0x1) > > close(2) = 0 (0x0) > > write(1,"\n",1) ERR#22 'Invalid > > argument' > > failed > > FreeBSD lost the ability of doing such transparent > transformations when the support for block devices > went away. > > Yes, I know, it feels awkward. > > Apparently, you can easily drop the support for block > devices but not the habitual feeling of danger of UNIX > tradition. Thanks for the enlightening information. Although I didn't doubt that this was safe I couldn't help feeling that it seemed "a wrong thing to do" - a case of old habits being hard to loose. After seeing your explanation I feel much more confident about this. It does seem a pity though that we have to rely on the side effect of having no support for writing to block devices instead of having a specific means of detecting or checking for a media change in the card reader. -- Mike Clarke